Page 1 of 1

Memory leak in WPG parser

Posted: 2016-09-20T06:49:16-07:00
by fumfel
When I try convert malformed WPG image, ImageMagick leaks memory in WPG parser.

IM Version (compiled from source):

Code: Select all

Version: ImageMagick 7.0.3-0 Q16 x86_64 2016-09-14 http://www.imagemagick.org
Source file

To reproduce:

Code: Select all

convert crash.wpg a.jpg
LeakSanitizer Output:

Code: Select all

==19859==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 7585 byte(s) in 1 object(s) allocated from:
    #0 0x7f7c83446602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f7c82e83a1c in UnpackWPG2Raster coders/wpg.c:578
    #2 0x7f7c82e83a1c in ReadWPGImage coders/wpg.c:1356

SUMMARY: AddressSanitizer: 7585 byte(s) leaked in 1 allocation(s).
Found with American Fuzzy Lop ( http://lcamtuf.coredump.cx/afl/ )

Re: Memory leak in WPG parser

Posted: 2016-09-20T07:40:16-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.