]> granicus.if.org Git - imagemagick/commitdiff
Fixed various leaks reported in #460.
authorDirk Lemstra <dirk@git.imagemagick.org>
Tue, 2 May 2017 06:26:55 +0000 (08:26 +0200)
committerDirk Lemstra <dirk@git.imagemagick.org>
Tue, 2 May 2017 06:26:55 +0000 (08:26 +0200)
coders/pdb.c

index 799bc7efa7122820c1a6c12a15ac76fd1af96f89..428f040d7dc664a048a24c231f0a08c8c6d55ee7 100644 (file)
@@ -424,19 +424,25 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     case 0:
     {
       image->compression=NoCompression;
-      count=(ssize_t) ReadBlob(image, packets * image -> rows, pixels);
+      count=(ssize_t) ReadBlob(image,packets*image->rows,pixels);
       break;
     }
     case 1:
     {
       image->compression=RLECompression;
-      if (!DecodeImage(image, pixels, packets * image -> rows))
-        ThrowReaderException( CorruptImageError, "RLEDecoderError" );
+      if (!DecodeImage(image,pixels,packets*image->rows))
+        {
+          pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+          ThrowReaderException(CorruptImageError,"RLEDecoderError");
+        }
       break;
     }
     default:
+    {
+      pixels=(unsigned char *) RelinquishMagickMemory(pixels);
       ThrowReaderException(CorruptImageError,
-         "UnrecognizedImageCompressionType" );
+        "UnrecognizedImageCompressionType");
+    }
   }
   p=pixels;
   switch (bits_per_pixel)
@@ -541,7 +547,10 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       break;
     }
     default:
+    {
+      pixels=(unsigned char *) RelinquishMagickMemory(pixels);
       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+    }
   }
   pixels=(unsigned char *) RelinquishMagickMemory(pixels);
   if (EOFBlob(image) != MagickFalse)