]> granicus.if.org Git - imagemagick/commitdiff
fix memory leak in gif
authorroot <356986351@qq.com>
Fri, 15 Sep 2017 16:51:13 +0000 (16:51 +0000)
committerDirk Lemstra <dlemstra@users.noreply.github.com>
Sat, 16 Sep 2017 13:29:09 +0000 (15:29 +0200)
coders/gif.c

index 6202f5e1663f1ac2fef15e2a1dbf2918b8b333d8..d87279f5fb020d44985227be2a388b2920e9ad0a 100644 (file)
@@ -1156,6 +1156,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 if (info == (unsigned char *) NULL)
                   {
                     meta_image=DestroyImage(meta_image);
+                    global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap);
                     ThrowReaderException(ResourceLimitError,
                       "MemoryAllocationFailed");
                   }
@@ -1174,6 +1175,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       if (info == (unsigned char *) NULL)
                         {
                           meta_image=DestroyImage(meta_image);
+                          global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap);
                           ThrowReaderException(ResourceLimitError,
                             "MemoryAllocationFailed");
                         }
@@ -1183,6 +1185,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 if (profile == (StringInfo *) NULL)
                   {
                     meta_image=DestroyImage(meta_image);
+                    global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap);
                     ThrowReaderException(ResourceLimitError,
                       "MemoryAllocationFailed");
                   }
@@ -1355,7 +1358,11 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
         break;
     status=SetImageExtent(image,image->columns,image->rows,exception);
     if (status == MagickFalse)
-      return(DestroyImageList(image));
+      {
+        global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap);
+        meta_image=DestroyImage(meta_image);
+        return(DestroyImageList(image));
+      }
     /*
       Decode image.
     */