]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/issues/815
authorCristy <urban-warrior@imagemagick.org>
Sat, 30 Sep 2017 15:19:39 +0000 (11:19 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 30 Sep 2017 15:19:39 +0000 (11:19 -0400)
MagickCore/compress.c

index fba05062260659bd0eec377f3ce7b990e9239979..35c38dd7c5ea5ffc0279e81cc79fcf45660b4c34 100644 (file)
@@ -456,8 +456,16 @@ MagickExport MagickBooleanType HuffmanDecodeImage(Image *image,
   if ((mb_hash == (HuffmanTable **) NULL) ||
       (mw_hash == (HuffmanTable **) NULL) ||
       (scanline == (unsigned char *) NULL))
-    ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
-      image->filename);
+    {
+      if (mb_hash != (HuffmanTable **) NULL)
+        mw_hash=(HuffmanTable **) RelinquishMagickMemory(mw_hash);
+      if (mw_hash != (HuffmanTable **) NULL)
+        mb_hash=(HuffmanTable **) RelinquishMagickMemory(mb_hash);
+      if (scanline != (unsigned char *) NULL)
+        scanline=(unsigned char *) RelinquishMagickMemory(scanline);
+      ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
+        image->filename);
+    }
   /*
     Initialize Huffman tables.
   */