Skip to content
Myr

stbi_read_fuzzer.c

This file

Path

tests/stbi_read_fuzzer.c

28 lines · 502 bytes · C

Last changed by

Merge branch 'fuzzer_updates' of https://github.com/randy408/stb into workingSean Barrettbefore adoption3152efa

History of this file

Take it

Merge branch 'fuzzer_updates' of https://github.com/randy408/stb into workingSean Barrettbefore adoption3152efa

lines 1–28why, one step back
1#ifdef __cplusplus
2extern "C" {3#endif45#define STB_IMAGE_IMPLEMENTATION67#include "../stb_image.h"8910int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)11{12 int x, y, channels;1314 if(!stbi_info_from_memory(data, size, &x, &y, &channels)) return 0;1516 /* exit if the image is larger than ~80MB */17 if(y && x > (80000000 / 4) / y) return 0;1819 unsigned char *img = stbi_load_from_memory(data, size, &x, &y, &channels, 4);2021 free(img);2223 return 0;24}2526#ifdef __cplusplus27}28#endif