Memory leak in WPG parser

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
fumfel
Posts: 12
Joined: 2016-09-20T06:30:11-07:00
Authentication code: 1151

Memory leak in WPG parser

Post 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/ )
Regards,
Kamil Frankowicz
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Memory leak in WPG parser

Post 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.
Post Reply