diff --git a/imageio/imageio_util.c b/imageio/imageio_util.c index df37137e..4ae4e03c 100644 --- a/imageio/imageio_util.c +++ b/imageio/imageio_util.c @@ -89,6 +89,11 @@ int ImgIoUtilReadFile(const char* const file_name, } fseek(in, 0, SEEK_END); file_size = ftell(in); + if (file_size == (size_t)-1) { + fclose(in); + WFPRINTF(stderr, "error getting size of '%s'\n", (const W_CHAR*)file_name); + return 0; + } fseek(in, 0, SEEK_SET); // we allocate one extra byte for the \0 terminator file_data = (uint8_t*)WebPMalloc(file_size + 1);