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

coders/sixel.c
coders/tim.c

index 51cc4eec7f0fc58254c237884316302fb620dc21..7af17f5aa9415696edd3d5c61b28618a5fa0daa7 100644 (file)
@@ -1034,7 +1034,11 @@ static Image *ReadSIXELImage(const ImageInfo *image_info,ExceptionInfo *exceptio
   image->storage_class=PseudoClass;
   status=SetImageExtent(image,image->columns,image->rows,exception);
   if (status == MagickFalse)
-    return(DestroyImageList(image));
+    {
+      sixel_pixels=(unsigned char *) RelinquishMagickMemory(sixel_pixels);
+      sixel_palette=(unsigned char *) RelinquishMagickMemory(sixel_palette);
+      return(DestroyImageList(image));
+    }
 
   if (AcquireImageColormap(image,image->colors, exception) == MagickFalse)
     {
index 7f87292c6a539167b03d4182a8b19e02dea95ddb..32af8e2684e2e0e141efc8cbba844d9268cbc65b 100644 (file)
@@ -240,7 +240,10 @@ static Image *ReadTIMImage(const ImageInfo *image_info,ExceptionInfo *exception)
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
     count=ReadBlob(image,image_size,tim_data);
     if (count != (ssize_t) (image_size))
-      ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
+      {
+        tim_data=(unsigned char *) RelinquishMagickMemory(tim_data);
+        ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
+      }
     tim_pixels=tim_data;
     /*
       Initialize image structure.
@@ -383,7 +386,10 @@ static Image *ReadTIMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         break;
       }
       default:
-        ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+        {
+          tim_data=(unsigned char *) RelinquishMagickMemory(tim_data);
+          ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+        }
     }
     if (image->storage_class == PseudoClass)
       (void) SyncImage(image,exception);