Memory leak coders/bmp.c
Posted: 2010-07-09T15:29:28-07:00
I got this problem on v6.6.2-10 and v6.6.3-0.
This is reproducible with some corrupt image files.
I'm using ImageMagick to do some batch operations on many JPEG files. Some of the input files were corrupted and it was causing a memory leak.
I had to use this patch to fix:
There could be more places where the function returns without free'ing 'pixels'
but this patch took care of the leak I was noticing.
Thanks. Sam.
This is reproducible with some corrupt image files.
I'm using ImageMagick to do some batch operations on many JPEG files. Some of the input files were corrupted and it was causing a memory leak.
I had to use this patch to fix:
Code: Select all
> cat ImageMagick.patch
diff -Naur ImageMagick-6.6.2-10/coders/bmp.c ImageMagick-6.6.2-10.new/coders/bmp.c
--- ImageMagick-6.6.2-10/coders/bmp.c 2010-06-02 17:53:06.000000000 -0700
+++ ImageMagick-6.6.2-10.new/coders/bmp.c 2010-07-02 22:47:01.000000000 -0700
@@ -909,8 +909,10 @@
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Reading pixels (%.20g bytes)",(double) length);
count=ReadBlob(image,length,pixels);
- if (count != (ssize_t) length)
+ if (count != (ssize_t) length) {
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
+ }
}
else
{
but this patch took care of the leak I was noticing.
Thanks. Sam.