2020-06-01 07:18:13 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-03-12 01:56:45 +03:00
|
|
|
#define STB_IMAGE_IMPLEMENTATION
|
2020-05-11 09:18:15 +03:00
|
|
|
|
2019-03-12 01:56:45 +03:00
|
|
|
#include "../stb_image.h"
|
|
|
|
|
2020-06-01 07:18:13 +03:00
|
|
|
|
2020-05-11 06:48:25 +03:00
|
|
|
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
2019-03-12 01:56:45 +03:00
|
|
|
{
|
|
|
|
int x, y, channels;
|
|
|
|
|
2019-03-12 02:59:20 +03:00
|
|
|
if(!stbi_info_from_memory(data, size, &x, &y, &channels)) return 0;
|
2019-03-12 01:56:45 +03:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
2020-06-01 07:18:13 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|