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

Side by Side Diff: fuzz/FilterFuzz.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 | « no previous file | fuzz/Fuzz.h » ('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 2013 Google Inc. 2 * Copyright 2013 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 #include "Fuzz.h" 7 #include "Fuzz.h"
8 #include "Sk1DPathEffect.h" 8 #include "Sk1DPathEffect.h"
9 #include "Sk2DPathEffect.h" 9 #include "Sk2DPathEffect.h"
10 #include "SkAlphaThresholdFilter.h" 10 #include "SkAlphaThresholdFilter.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 #define SK_ADD_RANDOM_BIT_FLIPS 51 #define SK_ADD_RANDOM_BIT_FLIPS
52 52
53 static Fuzz* fuzz; 53 static Fuzz* fuzz;
54 static const int kBitmapSize = 24; 54 static const int kBitmapSize = 24;
55 55
56 static bool return_large = false; 56 static bool return_large = false;
57 static bool return_undef = false; 57 static bool return_undef = false;
58 58
59 static int R(int x) { 59 static int R(int x) {
60 return abs(fuzz->next<int>()) % x; 60 int i; fuzz->nextRange(&i, 0, x-1);
61 return i;
61 } 62 }
62 63
63 #if defined _WIN32 64 #if defined _WIN32
64 #pragma warning ( push ) 65 #pragma warning ( push )
65 // we are intentionally causing an overflow here 66 // we are intentionally causing an overflow here
66 // (warning C4756: overflow in constant arithmetic) 67 // (warning C4756: overflow in constant arithmetic)
67 #pragma warning ( disable : 4756 ) 68 #pragma warning ( disable : 4756 )
68 #endif 69 #endif
69 70
70 static float huge() { 71 static float huge() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 case 4: return SkString("serif"); 125 case 4: return SkString("serif");
125 case 5: return SkString("Times"); 126 case 5: return SkString("Times");
126 case 6: return SkString("Times New Roman"); 127 case 6: return SkString("Times New Roman");
127 case 7: 128 case 7:
128 default: 129 default:
129 return make_string(); 130 return make_string();
130 } 131 }
131 } 132 }
132 133
133 static bool make_bool() { 134 static bool make_bool() {
134 return fuzz->next<bool>(); 135 bool b; fuzz->next(&b);
136 return b;
135 } 137 }
136 138
137 static SkRect make_rect() { 139 static SkRect make_rect() {
138 return SkRect::MakeWH(SkIntToScalar(R(static_cast<float>(kBitmapSize))), 140 return SkRect::MakeWH(SkIntToScalar(R(static_cast<float>(kBitmapSize))),
139 SkIntToScalar(R(static_cast<float>(kBitmapSize)))); 141 SkIntToScalar(R(static_cast<float>(kBitmapSize))));
140 } 142 }
141 143
142 static SkRegion make_region() { 144 static SkRegion make_region() {
143 SkIRect iRegion = SkIRect::MakeXYWH(R(static_cast<float>(kBitmapSize)), 145 SkIRect iRegion = SkIRect::MakeXYWH(R(static_cast<float>(kBitmapSize)),
144 R(static_cast<float>(kBitmapSize)), 146 R(static_cast<float>(kBitmapSize)),
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 764
763 DEF_FUZZ(SerializedImageFilter, f) { 765 DEF_FUZZ(SerializedImageFilter, f) {
764 fuzz = f; 766 fuzz = f;
765 767
766 SkPaint paint; 768 SkPaint paint;
767 paint.setImageFilter(make_serialized_image_filter()); 769 paint.setImageFilter(make_serialized_image_filter());
768 SkBitmap bitmap; 770 SkBitmap bitmap;
769 SkCanvas canvas(bitmap); 771 SkCanvas canvas(bitmap);
770 drawClippedBitmap(&canvas, 0, 0, paint); 772 drawClippedBitmap(&canvas, 0, 0, paint);
771 } 773 }
OLDNEW
« no previous file with comments | « no previous file | fuzz/Fuzz.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698