diff --git a/imageio/imageio_util.c b/imageio/imageio_util.c index 3ebd5b4e..10250093 100644 --- a/imageio/imageio_util.c +++ b/imageio/imageio_util.c @@ -137,7 +137,11 @@ void ImgIoUtilCopyPlane(const uint8_t* src, int src_stride, int ImgIoUtilCheckSizeArgumentsOverflow(uint64_t nmemb, size_t size) { const uint64_t total_size = nmemb * size; - return (total_size == (size_t)total_size); + int ok = (total_size == (size_t)total_size); +#if defined(WEBP_MAX_IMAGE_SIZE) + ok = ok && (total_size <= (uint64_t)WEBP_MAX_IMAGE_SIZE); +#endif + return ok; } // -----------------------------------------------------------------------------