/src/harfbuzz/test/fuzzing/hb-fuzzer.hh
Line | Count | Source |
1 | | #include <hb-config.hh> |
2 | | |
3 | | #include <hb.h> |
4 | | #include <stddef.h> |
5 | | |
6 | | extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size); |
7 | | |
8 | | #if defined(__GNUC__) && (__GNUC__ >= 4) || (__clang__) |
9 | | #define HB_UNUSED __attribute__((unused)) |
10 | | #else |
11 | | #define HB_UNUSED |
12 | | #endif |
13 | | |
14 | | #ifdef HB_IS_IN_FUZZER |
15 | | |
16 | | /* See src/failing-alloc.c */ |
17 | | extern "C" int alloc_state; |
18 | | |
19 | | #else |
20 | | |
21 | | /* Just a dummy global variable */ |
22 | | static int HB_UNUSED alloc_state = 0; |
23 | | |
24 | | #endif |
25 | | |
26 | | static inline int |
27 | | _fuzzing_alloc_state (const uint8_t *data, size_t size) |
28 | 81.9k | { |
29 | | /* https://github.com/harfbuzz/harfbuzz/pull/2764#issuecomment-1172589849 */ |
30 | | |
31 | | /* In 50% of the runs, don't fail the allocator. */ |
32 | 81.9k | if (size && data[size - 1] < 0x80) |
33 | 69.1k | return 0; |
34 | | |
35 | 12.7k | return size; |
36 | 81.9k | } hb-shape-fuzzer.cc:_fuzzing_alloc_state(unsigned char const*, unsigned long) Line | Count | Source | 28 | 36.4k | { | 29 | | /* https://github.com/harfbuzz/harfbuzz/pull/2764#issuecomment-1172589849 */ | 30 | | | 31 | | /* In 50% of the runs, don't fail the allocator. */ | 32 | 36.4k | if (size && data[size - 1] < 0x80) | 33 | 30.3k | return 0; | 34 | | | 35 | 6.07k | return size; | 36 | 36.4k | } |
Unexecuted instantiation: hb-repacker-fuzzer.cc:_fuzzing_alloc_state(unsigned char const*, unsigned long) hb-subset-fuzzer.cc:_fuzzing_alloc_state(unsigned char const*, unsigned long) Line | Count | Source | 28 | 23.6k | { | 29 | | /* https://github.com/harfbuzz/harfbuzz/pull/2764#issuecomment-1172589849 */ | 30 | | | 31 | | /* In 50% of the runs, don't fail the allocator. */ | 32 | 23.6k | if (size && data[size - 1] < 0x80) | 33 | 20.5k | return 0; | 34 | | | 35 | 3.19k | return size; | 36 | 23.6k | } |
hb-draw-fuzzer.cc:_fuzzing_alloc_state(unsigned char const*, unsigned long) Line | Count | Source | 28 | 21.7k | { | 29 | | /* https://github.com/harfbuzz/harfbuzz/pull/2764#issuecomment-1172589849 */ | 30 | | | 31 | | /* In 50% of the runs, don't fail the allocator. */ | 32 | 21.7k | if (size && data[size - 1] < 0x80) | 33 | 18.2k | return 0; | 34 | | | 35 | 3.42k | return size; | 36 | 21.7k | } |
hb-set-fuzzer.cc:_fuzzing_alloc_state(unsigned char const*, unsigned long) Line | Count | Source | 28 | 102 | { | 29 | | /* https://github.com/harfbuzz/harfbuzz/pull/2764#issuecomment-1172589849 */ | 30 | | | 31 | | /* In 50% of the runs, don't fail the allocator. */ | 32 | 102 | if (size && data[size - 1] < 0x80) | 33 | 59 | return 0; | 34 | | | 35 | 43 | return size; | 36 | 102 | } |
|