]> granicus.if.org Git - imagemagick/commitdiff
Fixed memory leak reported in #458.
authorDirk Lemstra <dirk@git.imagemagick.org>
Tue, 2 May 2017 06:38:06 +0000 (08:38 +0200)
committerDirk Lemstra <dirk@git.imagemagick.org>
Tue, 2 May 2017 06:38:06 +0000 (08:38 +0200)
coders/mpc.c

index 2b8e6ab92fb297d5a49558a4a4c08d8055b9f5a3..8088da4925c6ec3d44319120475379ae7b8f28b5 100644 (file)
@@ -872,12 +872,16 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
               ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
             count=ReadBlob(image,packet_size*image->colors,colormap);
             if (count != (ssize_t) (packet_size*image->colors))
-              ThrowReaderException(CorruptImageError,
-                "InsufficientImageDataInFile");
+              {
+                colormap=(unsigned char *) RelinquishMagickMemory(colormap);
+                ThrowReaderException(CorruptImageError,
+                  "InsufficientImageDataInFile");
+              }
             p=colormap;
             switch (depth)
             {
               default:
+                colormap=(unsigned char *) RelinquishMagickMemory(colormap);
                 ThrowReaderException(CorruptImageError,
                   "ImageDepthNotSupported");
               case 8: