OLD | NEW |
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 #ifndef Fuzz_DEFINED | 8 #ifndef Fuzz_DEFINED |
9 #define Fuzz_DEFINED | 9 #define Fuzz_DEFINED |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 */ | 40 */ |
41 float nextRangeF(float min, float max); | 41 float nextRangeF(float min, float max); |
42 | 42 |
43 void signalBug (); // Tell afl-fuzz these inputs found a bug. | 43 void signalBug (); // Tell afl-fuzz these inputs found a bug. |
44 void signalBoring(); // Tell afl-fuzz these inputs are not worth testing. | 44 void signalBoring(); // Tell afl-fuzz these inputs are not worth testing. |
45 | 45 |
46 private: | 46 private: |
47 template <typename T> | 47 template <typename T> |
48 T nextT(); | 48 T nextT(); |
49 | 49 |
50 SkAutoTUnref<SkData> fBytes; | 50 sk_sp<SkData> fBytes; |
51 int fNextByte; | 51 int fNextByte; |
52 }; | 52 }; |
53 | 53 |
54 template <typename T> | 54 template <typename T> |
55 bool Fuzz::next(T* n) { | 55 bool Fuzz::next(T* n) { |
56 if (fNextByte + sizeof(T) > fBytes->size()) { | 56 if (fNextByte + sizeof(T) > fBytes->size()) { |
57 return false; | 57 return false; |
58 } | 58 } |
59 | 59 |
60 memcpy(n, fBytes->bytes() + fNextByte, sizeof(T)); | 60 memcpy(n, fBytes->bytes() + fNextByte, sizeof(T)); |
61 fNextByte += sizeof(T); | 61 fNextByte += sizeof(T); |
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
65 struct Fuzzable { | 65 struct Fuzzable { |
66 const char* name; | 66 const char* name; |
67 void (*fn)(Fuzz*); | 67 void (*fn)(Fuzz*); |
68 }; | 68 }; |
69 | 69 |
70 #define DEF_FUZZ(name, f) \ | 70 #define DEF_FUZZ(name, f) \ |
71 static void fuzz_##name(Fuzz*); \ | 71 static void fuzz_##name(Fuzz*); \ |
72 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ | 72 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ |
73 static void fuzz_##name(Fuzz* f) | 73 static void fuzz_##name(Fuzz* f) |
74 | 74 |
75 #endif//Fuzz_DEFINED | 75 #endif//Fuzz_DEFINED |
OLD | NEW |