memory leak when deal with corrupted png: 6.7.9

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
zhcn381
Posts: 17
Joined: 2012-07-05T02:34:18-07:00
Authentication code: 13

memory leak when deal with corrupted png: 6.7.9

Post by zhcn381 » 2012-10-08T06:40:30-07:00

hi, magick

I'm working on observing our production system's memory leak problem recently. Unfortunately I found another memory leak in ImageMagick. Although it's not a big deal, I still put it here to let you know. Again, it's a corrupted png. It also exists in early version like 6.2.8. I noticed that when the following setjmp is returned through longjmp, the value of ping_pixels will be NULL, so when you switch "gcc -O " on, the code which is responsible for releasing the resources is optimized by the compile.

Code: Select all

      if (ping_pixels != (unsigned char *) NULL)
        ping_pixels=(unsigned char *) RelinquishMagickMemory(ping_pixels);
Here is the patch, pls check it:

Code: Select all

Index: coders/png.c                                                                                                                   
===================================================================
--- coders/png.c  (revision 9547)
+++ coders/png.c  (working copy)
@@ -2038,7 +2038,7 @@
     x_resolution,
     y_resolution;

-  unsigned char
+  unsigned char volatile
     *ping_pixels;

   ssize_t
Again, I will upload the corrupted png here. I can't find where I can post an attachment.

User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: memory leak when deal with corrupted png: 6.7.9

Post by magick » 2012-10-08T07:03:12-07:00

Thanks for the problem report and patch. We'll apply the patch to ImageMagick 6.8.0-0 Beta by sometime tomorrow.

zhcn381
Posts: 17
Joined: 2012-07-05T02:34:18-07:00
Authentication code: 13

Re: memory leak when deal with corrupted png: 6.7.9

Post by zhcn381 » 2012-10-08T19:01:21-07:00

hi, magick

I'm sorry. It's

Code: Select all

unsigned char  * volatile ping_pixels
not

Code: Select all

unsigned char volatile * ping_pixels

User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: memory leak when deal with corrupted png: 6.7.9

Post by magick » 2012-10-09T03:41:14-07:00

Right we spotted that correction when we applied the patch. Thanks.

Post Reply