Page 1 of 1

Memory leak in coders/jp2.c

Posted: 2011-12-28T13:14:08-07:00
by visionofarun
Hi,

I encountered a memory leak in the coders/jp2.c. I had sent a mail to the imagemagick-bugs mailing list. I was asked to report it here.

Here is the patch for the memory leak. This affects all versions (trunk and stable).

Code: Select all

Index: coders/jp2.c
===================================================================
--- coders/jp2.c        (revision 6269)
+++ coders/jp2.c        (working copy)
@@ -1011,6 +1011,11 @@
  status=jas_image_encode(jp2_image,jp2_stream,format,options) != 0 ?
    MagickTrue : MagickFalse;
  (void) jas_stream_close(jp2_stream);
+  if (options)
+  {
+     free(options);
+     options = (char *) NULL;
+  }
  for (i=0; i < (ssize_t) number_components; i++)
    jas_matrix_destroy(pixels[i]);
  jas_image_destroy(jp2_image);
Regards,
Arun

Re: Memory leak in coders/jp2.c

Posted: 2011-12-28T14:48:23-07:00
by magick
Thanks for the problem report and patch. We'll get the patch into ImageMagick 6.7.4-3 Beta by sometime tomorrow.

Re: Memory leak in coders/jp2.c

Posted: 2011-12-29T01:30:55-07:00
by visionofarun
Thanks for your reply. I am wondering if the Windows binary package will be updated with the memory leak fix.

Re: Memory leak in coders/jp2.c

Posted: 2011-12-29T07:03:55-07:00
by magick
Yes, when ImageMagick 6.7.4-3 is release within a few weeks.