From: Cristy Date: Sat, 30 Sep 2017 14:36:06 +0000 (-0400) Subject: https://github.com/ImageMagick/ImageMagick/issues/808 X-Git-Tag: 7.0.7-5~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24d5699753170c141b46816284430516c2d48fed;p=imagemagick https://github.com/ImageMagick/ImageMagick/issues/808 --- diff --git a/coders/gif.c b/coders/gif.c index a2bfe2f09..f68e31002 100644 --- a/coders/gif.c +++ b/coders/gif.c @@ -1562,7 +1562,14 @@ static MagickBooleanType WriteGIFImage(const ImageInfo *image_info,Image *image, colormap=(unsigned char *) AcquireQuantumMemory(768UL,sizeof(*colormap)); if ((global_colormap == (unsigned char *) NULL) || (colormap == (unsigned char *) NULL)) - ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); + { + if (global_colormap != (unsigned char *) NULL) + global_colormap=(unsigned char *) RelinquishMagickMemory( + global_colormap); + if (colormap != (unsigned char *) NULL) + colormap=(unsigned char *) RelinquishMagickMemory(colormap); + ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); + } for (i=0; i < 768; i++) colormap[i]=(unsigned char) 0; /*