/src/stb/tests/stbi_read_fuzzer.c
Line | Count | Source |
1 | | #ifdef __cplusplus |
2 | | extern "C" { |
3 | | #endif |
4 | | |
5 | | #define STB_IMAGE_IMPLEMENTATION |
6 | | |
7 | | #include "../stb_image.h" |
8 | | |
9 | | |
10 | | int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) |
11 | 268 | { |
12 | 268 | int x, y, channels; |
13 | | |
14 | 268 | if(!stbi_info_from_memory(data, size, &x, &y, &channels)) return 0; |
15 | | |
16 | | /* exit if the image is larger than ~80MB */ |
17 | 268 | if(y && x > (80000000 / 4) / y) return 0; |
18 | | |
19 | 268 | unsigned char *img = stbi_load_from_memory(data, size, &x, &y, &channels, 4); |
20 | | |
21 | 268 | free(img); |
22 | | |
23 | 268 | return 0; |
24 | 268 | } |
25 | | |
26 | | #ifdef __cplusplus |
27 | | } |
28 | | #endif |