From: Cristy Date: Sat, 30 Sep 2017 15:19:39 +0000 (-0400) Subject: https://github.com/ImageMagick/ImageMagick/issues/815 X-Git-Tag: 7.0.7-5~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c6df699eee13cb93b5bd4c045f5b97d52ca35f3;p=imagemagick https://github.com/ImageMagick/ImageMagick/issues/815 --- 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. */