From: Dirk Lemstra Date: Fri, 16 Mar 2018 11:35:40 +0000 (+0100) Subject: Fixed reading uninitialised memory. X-Git-Tag: 7.0.7-27~42 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c47b6dbd25f8e1ef89bf905793cd22a7e89638b9;p=imagemagick Fixed reading uninitialised memory. --- diff --git a/coders/pcd.c b/coders/pcd.c index b990952e1..da8534859 100644 --- a/coders/pcd.c +++ b/coders/pcd.c @@ -537,9 +537,13 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception) if (header == (unsigned char *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); count=ReadBlob(image,3*0x800,header); + if (count != (3*0x800)) + { + header=(unsigned char *) RelinquishMagickMemory(header); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + } overview=LocaleNCompare((char *) header,"PCD_OPA",7) == 0; - if ((count != (3*0x800)) || - ((LocaleNCompare((char *) header+0x800,"PCD",3) != 0) && (overview ==0))) + if ((LocaleNCompare((char *) header+0x800,"PCD",3) != 0) && (overview == 0)) { header=(unsigned char *) RelinquishMagickMemory(header); ThrowReaderException(CorruptImageError,"ImproperImageHeader");