Fixed various leaks reported in #460.
diff --git a/coders/pdb.c b/coders/pdb.c
index 799bc7e..428f040 100644
--- a/coders/pdb.c
+++ b/coders/pdb.c
@@ -424,19 +424,25 @@
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 @@
break;
}
default:
+ {
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+ }
}
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (EOFBlob(image) != MagickFalse)