From c945953a9acfd7f0ec935b32daec37e9e2f4e574 Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 4 May 2018 09:13:13 -0400 Subject: [PATCH] ... --- coders/png.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/coders/png.c b/coders/png.c index 9ed76735b..0bcdcf721 100644 --- a/coders/png.c +++ b/coders/png.c @@ -4502,7 +4502,14 @@ static Image *ReadOneJNGImage(MngInfo *mng_info, { DestroyJNG(NULL,&color_image,&color_image_info, &alpha_image,&alpha_image_info); - ThrowReaderException(CorruptImageError,"CorruptImage"); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + } + if (length > GetBlobSize(image)) + { + DestroyJNG(NULL,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(CorruptImageError, + "InsufficientImageDataInFile"); } p=NULL; @@ -4510,13 +4517,6 @@ static Image *ReadOneJNGImage(MngInfo *mng_info, if (length != 0) { - if (length > GetBlobSize(image)) - { - DestroyJNG(NULL,&color_image,&color_image_info, - &alpha_image,&alpha_image_info); - ThrowReaderException(CorruptImageError, - "InsufficientImageDataInFile"); - } chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk)); if (chunk == (unsigned char *) NULL) -- 2.40.0