Page 1 of 1

Memory leak in GIF parser

Posted: 2016-09-20T08:44:46-07:00
by fumfel
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.gif a.jpg
LeakSanitizer output:

Code: Select all

==32663==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 13304 byte(s) in 1 object(s) allocated from:
    #0 0x7f7395444602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f7394745d0f in AcquireImage MagickCore/image.c:168

Indirect leak of 12832 byte(s) in 1 object(s) allocated from:
    #0 0x7f7395444602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f7394730f67 in AcquireImageInfo MagickCore/image.c:346

Indirect leak of 9072 byte(s) in 1 object(s) allocated from:
    #0 0x7f7395444602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f73944a6d43 in AcquirePixelCache MagickCore/cache.c:192

Indirect leak of 512 byte(s) in 1 object(s) allocated from:
    #0 0x7f7395444602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f739480ee4c in AcquirePixelChannelMap MagickCore/pixel.c:101

Indirect leak of 352 byte(s) in 1 object(s) allocated from:
    #0 0x7f7395444602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f73944a6571 in AcquirePixelCacheNexus MagickCore/cache.c:259

Indirect leak of 320 byte(s) in 5 object(s) allocated from:
    #0 0x7f7395445076 in __interceptor_posix_memalign (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99076)
    #1 0x7f7394a4296f in AcquireSemaphoreMemory MagickCore/semaphore.c:153
    #2 0x7f7394a4296f in AcquireSemaphoreInfo MagickCore/semaphore.c:199

Indirect leak of 272 byte(s) in 1 object(s) allocated from:
    #0 0x7f7395444602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f739447097a in CloneBlobInfo MagickCore/blob.c:446

Indirect leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x7f7395444602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f7394a723b4 in NewSplayTree MagickCore/splay-tree.c:1106

Indirect leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7f7395445076 in __interceptor_posix_memalign (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99076)
    #1 0x7f73947a428c in AcquireAlignedMemory MagickCore/memory.c:258

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f7395444602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f7394a6d109 in AddValueToSplayTree MagickCore/splay-tree.c:188

Indirect leak of 24 byte(s) in 2 object(s) allocated from:
    #0 0x7f7395444602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f7394ac7d09 in ConstantString MagickCore/string.c:701

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

Re: Memory leak in GIF parser

Posted: 2016-09-20T08:55:58-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.