]> granicus.if.org Git - imagemagick/commitdiff
Fixed memory leaks
authorDirk Lemstra <dirk@git.imagemagick.org>
Sun, 18 Mar 2018 10:49:38 +0000 (11:49 +0100)
committerDirk Lemstra <dirk@git.imagemagick.org>
Sun, 18 Mar 2018 10:49:38 +0000 (11:49 +0100)
coders/gif.c

index e45f2487d819255d6f05498ee2469fe4eaa3720d..6b93cffc25883ede570d44185389e5ab2cdf3380 100644 (file)
@@ -1035,22 +1035,14 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   global_colormap=(unsigned char *) AcquireQuantumMemory((size_t)
     MagickMax(global_colors,256),3UL*sizeof(*global_colormap));
   if (global_colormap == (unsigned char *) NULL)
-    {
-      meta_image=DestroyImage(meta_image);
-      ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-    }
+    ThrowGIFException(ResourceLimitError,"MemoryAllocationFailed");
   (void) memset(global_colormap,0,3*MagickMax(global_colors,256)*
     sizeof(*global_colormap));
   if (BitSet((int) flag,0x80) != 0)
     {
       count=ReadBlob(image,(size_t) (3*global_colors),global_colormap);
       if (count != (ssize_t) (3*global_colors))
-        {
-          global_colormap=(unsigned char *) RelinquishMagickMemory(
-            global_colormap);
-          meta_image=DestroyImage(meta_image);
-          ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
-        }
+        ThrowGIFException(CorruptImageError,"InsufficientImageDataInFile");
     }
   profiles=(LinkedListInfo *) NULL;
   duration=0;
@@ -1185,7 +1177,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       if (info == (unsigned char *) NULL)
                         {
                           info=(unsigned char *) RelinquishMagickMemory(info);
-                          ThrowReaderException(ResourceLimitError,
+                          ThrowGIFException(ResourceLimitError,
                             "MemoryAllocationFailed");
                         }
                     }
@@ -1194,7 +1186,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 if (profile == (StringInfo *) NULL)
                   {
                     info=(unsigned char *) RelinquishMagickMemory(info);
-                    ThrowReaderException(ResourceLimitError,
+                    ThrowGIFException(ResourceLimitError,
                       "MemoryAllocationFailed");
                   }
                 if (i8bim != MagickFalse)
@@ -1277,7 +1269,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     image->ticks_per_second=100;
     image->alpha_trait=opacity >= 0 ? BlendPixelTrait : UndefinedPixelTrait;
     if ((image->columns == 0) || (image->rows == 0))
-      ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
+      ThrowGIFException(CorruptImageError,"NegativeOrZeroImageSize");
     /*
       Inititialize colormap.
     */