From c47b6dbd25f8e1ef89bf905793cd22a7e89638b9 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Fri, 16 Mar 2018 12:35:40 +0100 Subject: [PATCH] Fixed reading uninitialised memory. --- coders/pcd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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"); -- 2.40.0