]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/issues/453
authorCristy <urban-warrior@imagemagick.org>
Wed, 26 Apr 2017 21:39:46 +0000 (17:39 -0400)
committerCristy <urban-warrior@imagemagick.org>
Wed, 26 Apr 2017 21:39:46 +0000 (17:39 -0400)
coders/ept.c

index 37b34e4f9681c9fef8763b8e6c595876b5add08a..41382426c3fd8fbd75df5fd641d81956e5878b51 100644 (file)
@@ -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,