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

Side by Side Diff: fuzz/FuzzScaleToSides.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/FuzzPathop.cpp ('k') | no next file » | 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 // Reminder of how to run: 8 // Reminder of how to run:
9 // $ env CC=afl-clang CXX=afl-clang++ ./gyp_skia 9 // $ env CC=afl-clang CXX=afl-clang++ ./gyp_skia
10 // $ ninja -C out/Debug fuzz 10 // $ ninja -C out/Debug fuzz
11 // $ afl-fuzz -i fuzz-in -o fuzz-out out/Debug/fuzz -n ScaleToSides -b @@ 11 // $ afl-fuzz -i fuzz-in -o fuzz-out out/Debug/fuzz -n ScaleToSides -b @@
12 // where you seed fuzz-in/ with one or more small files. 12 // where you seed fuzz-in/ with one or more small files.
13 13
14 #include "Fuzz.h" 14 #include "Fuzz.h"
15 #include "SkScaleToSides.h" 15 #include "SkScaleToSides.h"
16 #include <cmath> 16 #include <cmath>
17 17
18 DEF_FUZZ(ScaleToSides, fuzz) { 18 DEF_FUZZ(ScaleToSides, fuzz) {
19 float radius1 = fuzz->next<float>(), 19 float radius1, radius2, width;
20 radius2 = fuzz->next<float>(), 20 fuzz->next(&radius1, &radius2, &width);
21 width = fuzz->next<float>();
22 21
23 if (!std::isfinite(radius1) || 22 if (!std::isfinite(radius1) ||
24 !std::isfinite(radius2) || 23 !std::isfinite(radius2) ||
25 !std::isfinite(width) || 24 !std::isfinite(width) ||
26 radius1 <= 0.0f || 25 radius1 <= 0.0f ||
27 radius2 <= 0.0f || 26 radius2 <= 0.0f ||
28 width <= 0.0f) 27 width <= 0.0f)
29 { 28 {
30 return; 29 return;
31 } 30 }
32 31
33 double scale = (double)width / ((double)radius1 + (double)radius2); 32 double scale = (double)width / ((double)radius1 + (double)radius2);
34 if (scale >= 1.0 || scale <= 0.0) { 33 if (scale >= 1.0 || scale <= 0.0) {
35 return; 34 return;
36 } 35 }
37 SkDebugf("%g %g %g %g\n", radius1, radius2, width, scale); 36 SkDebugf("%g %g %g %g\n", radius1, radius2, width, scale);
38 SkScaleToSides::AdjustRadii(width, scale, &radius1, &radius2); 37 SkScaleToSides::AdjustRadii(width, scale, &radius1, &radius2);
39 38
40 // TODO(mtklein): add fuzz->keepResult() 39 // TODO(mtklein): add fuzz->keepResult()
41 volatile float junk = 0.0f; 40 volatile float junk = 0.0f;
42 junk *= radius1; 41 junk *= radius1;
43 junk *= radius2; 42 junk *= radius2;
44 } 43 }
OLDNEW
« no previous file with comments | « fuzz/FuzzPathop.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698