From 7c6df699eee13cb93b5bd4c045f5b97d52ca35f3 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 30 Sep 2017 11:19:39 -0400 Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/815 --- MagickCore/compress.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MagickCore/compress.c b/MagickCore/compress.c index fba050622..35c38dd7c 100644 --- a/MagickCore/compress.c +++ b/MagickCore/compress.c @@ -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. */ -- 2.40.0