Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Side by Side Diff: fuzz/FuzzPathop.cpp

Issue 2478593003: Avoid params being initialized out of order in Fuzzer (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fuzz/FuzzParsePath.cpp ('k') | fuzz/FuzzScaleToSides.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Fuzz.h" 8 #include "Fuzz.h"
9 #include "SkPath.h" 9 #include "SkPath.h"
10 #include "SkPathOps.h" 10 #include "SkPathOps.h"
11 11
12 const int kLastOp = SkPathOp::kReverseDifference_SkPathOp; 12 const int kLastOp = SkPathOp::kReverseDifference_SkPathOp;
13 13
14 void BuildPath(Fuzz* fuzz, 14 void BuildPath(Fuzz* fuzz,
15 SkPath* path, 15 SkPath* path,
16 int last_verb) { 16 int last_verb) {
17 while (!fuzz->exhausted()) { 17 while (!fuzz->exhausted()) {
18 uint8_t operation = fuzz->next<uint8_t>(); 18 uint8_t operation; fuzz->next(&operation);
19 SkScalar a,b,c,d,e,f;
19 20
20 switch (operation % (last_verb + 1)) { 21 switch (operation % (last_verb + 1)) {
21 case SkPath::Verb::kMove_Verb: 22 case SkPath::Verb::kMove_Verb:
22 path->moveTo(fuzz->next<SkScalar>(), fuzz->next<SkScalar>()); 23 fuzz->next(&a, &b);
24 path->moveTo(a, b);
23 break; 25 break;
24 26
25 case SkPath::Verb::kLine_Verb: 27 case SkPath::Verb::kLine_Verb:
26 path->lineTo(fuzz->next<SkScalar>(), fuzz->next<SkScalar>()); 28 fuzz->next(&a, &b);
29 path->lineTo(a, b);
27 break; 30 break;
28 31
29 case SkPath::Verb::kQuad_Verb: 32 case SkPath::Verb::kQuad_Verb:
30 path->quadTo(fuzz->next<SkScalar>(), fuzz->next<SkScalar>(), 33 fuzz->next(&a, &b, &c, &d);
31 fuzz->next<SkScalar>(), fuzz->next<SkScalar>()); 34 path->quadTo(a, b, c, d);
32 break; 35 break;
33 36
34 case SkPath::Verb::kConic_Verb: 37 case SkPath::Verb::kConic_Verb:
35 path->conicTo(fuzz->next<SkScalar>(), fuzz->next<SkScalar>(), 38 fuzz->next(&a, &b, &c, &d, &e);
36 fuzz->next<SkScalar>(), fuzz->next<SkScalar>(), 39 path->conicTo(a, b, c, d, e);
37 fuzz->next<SkScalar>());
38 break; 40 break;
39 41
40 case SkPath::Verb::kCubic_Verb: 42 case SkPath::Verb::kCubic_Verb:
41 path->cubicTo(fuzz->next<SkScalar>(), fuzz->next<SkScalar>(), 43 fuzz->next(&a, &b, &c, &d, &e, &f);
42 fuzz->next<SkScalar>(), fuzz->next<SkScalar>(), 44 path->cubicTo(a, b, c, d, e, f);
43 fuzz->next<SkScalar>(), fuzz->next<SkScalar>());
44 break; 45 break;
45 46
46 case SkPath::Verb::kClose_Verb: 47 case SkPath::Verb::kClose_Verb:
47 path->close(); 48 path->close();
48 break; 49 break;
49 50
50 case SkPath::Verb::kDone_Verb: 51 case SkPath::Verb::kDone_Verb:
51 // In this case, simply exit. 52 // In this case, simply exit.
52 return; 53 return;
53 } 54 }
54 } 55 }
55 } 56 }
56 57
57 DEF_FUZZ(Pathop, fuzz) { 58 DEF_FUZZ(Pathop, fuzz) {
58 SkOpBuilder builder; 59 SkOpBuilder builder;
59 60
60 uint8_t stragglerOp = fuzz->next<uint8_t>(); 61 uint8_t stragglerOp; fuzz->next(&stragglerOp);
61 SkPath path; 62 SkPath path;
62 63
63 BuildPath(fuzz, &path, SkPath::Verb::kDone_Verb); 64 BuildPath(fuzz, &path, SkPath::Verb::kDone_Verb);
64 builder.add(path, static_cast<SkPathOp>(stragglerOp % (kLastOp + 1))); 65 builder.add(path, static_cast<SkPathOp>(stragglerOp % (kLastOp + 1)));
65 66
66 SkPath result; 67 SkPath result;
67 builder.resolve(&result); 68 builder.resolve(&result);
68 } 69 }
OLDNEW
« no previous file with comments | « fuzz/FuzzParsePath.cpp ('k') | fuzz/FuzzScaleToSides.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698