From: Cristy Date: Wed, 26 Apr 2017 21:39:46 +0000 (-0400) Subject: https://github.com/ImageMagick/ImageMagick/issues/453 X-Git-Tag: 7.0.5-6~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e82f14da961e607f1b6ffa525644535686070228;p=imagemagick https://github.com/ImageMagick/ImageMagick/issues/453 --- diff --git a/coders/ept.c b/coders/ept.c index 37b34e4f9..41382426c 100644 --- a/coders/ept.c +++ b/coders/ept.c @@ -210,19 +210,33 @@ static Image *ReadEPTImage(const ImageInfo *image_info,ExceptionInfo *exception) ept_info.tiff=(unsigned char *) AcquireQuantumMemory(ept_info.tiff_length+1, sizeof(*ept_info.tiff)); if (ept_info.tiff == (unsigned char *) NULL) - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + { + ept_info.postscript=(unsigned char *) RelinquishMagickMemory( + ept_info.postscript); + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + } (void) ResetMagickMemory(ept_info.tiff,0,(ept_info.tiff_length+1)* sizeof(*ept_info.tiff)); offset=SeekBlob(image,ept_info.tiff_offset,SEEK_SET); if ((ept_info.tiff_length != 0) && (offset < 30)) - ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + { + ept_info.tiff=(unsigned char *) RelinquishMagickMemory(ept_info.tiff); + ept_info.postscript=(unsigned char *) RelinquishMagickMemory( + ept_info.postscript); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + } count=ReadBlob(image,ept_info.tiff_length,ept_info.tiff); if (count != (ssize_t) (ept_info.tiff_length)) (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageWarning, "InsufficientImageDataInFile","`%s'",image->filename); offset=SeekBlob(image,ept_info.postscript_offset,SEEK_SET); if ((ept_info.postscript_length != 0) && (offset < 30)) - ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + { + ept_info.tiff=(unsigned char *) RelinquishMagickMemory(ept_info.tiff); + ept_info.postscript=(unsigned char *) RelinquishMagickMemory( + ept_info.postscript); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + } count=ReadBlob(image,ept_info.postscript_length,ept_info.postscript); if (count != (ssize_t) (ept_info.postscript_length)) (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageWarning,