From 24d5699753170c141b46816284430516c2d48fed Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 30 Sep 2017 10:36:06 -0400 Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/808 --- coders/gif.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; /* -- 2.40.0