mirror of
https://github.com/nothings/stb
synced 2024-12-16 04:42:42 +03:00
20 lines
464 B
C++
20 lines
464 B
C++
|
#define STB_IMAGE_IMPLEMENTATION
|
||
|
#define STBI_ONLY_PNG
|
||
|
#include "../stb_image.h"
|
||
|
|
||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||
|
{
|
||
|
int x, y, channels;
|
||
|
|
||
|
if(stbi_info_from_memory(data, size, &x, &y, &channels)) return 0;
|
||
|
|
||
|
/* exit if the image is larger than ~80MB */
|
||
|
if(y && x > (80000000 / 4) / y) return 0;
|
||
|
|
||
|
unsigned char *img = stbi_load_from_memory(data, size, &x, &y, &channels, 4);
|
||
|
|
||
|
free(img);
|
||
|
|
||
|
return 0;
|
||
|
}
|