]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/issues/808
authorCristy <urban-warrior@imagemagick.org>
Sat, 30 Sep 2017 14:36:06 +0000 (10:36 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 30 Sep 2017 14:36:06 +0000 (10:36 -0400)
coders/gif.c

index a2bfe2f099ee4ed1b04f5241a91d515022787718..f68e31002d898c8b827d8243d007d60aae59489a 100644 (file)
@@ -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;
   /*