memory leak in function ReadMPCImage of coders/mpc.c
Swiss army knife of image processing
Brought to you by:
bfriesen
There is a memory leak in function ReadMPCImage of coders/mpc.c whick can be reproduced as below.
./graphicsmagick-code/utilities/gm convert ./memory_leak_ReadMPCImage /dev/null
=================================================================
==79854==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 2304 byte(s) in 9 object(s) allocated from:
#0 0x7f0c8eb25602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
#1 0x4de2d4 in MagickMalloc magick/memory.c:173
#2 0x582e40 in AllocateString magick/utility.c:202
#3 0x733446 in ReadMPCImage coders/mpc.c:638
#4 0x47766b in ReadImage magick/constitute.c:1607
#5 0x4214e9 in ConvertImageCommand magick/command.c:4362
#6 0x436a5e in MagickCommand magick/command.c:8886
#7 0x45f205 in GMCommandSingle magick/command.c:17416
#8 0x45f451 in GMCommand magick/command.c:17469
#9 0x40cbc5 in main utilities/gm.c:61
#10 0x7f0c8bd9882f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
SUMMARY: AddressSanitizer: 2304 byte(s) leaked in 9 allocation(s).
System Configuration:
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
GraphicsMagick version:
GraphicsMagick 1.4 snapshot-20190322 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2019 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Feature Support:
Native Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) yes
BZIP yes
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG yes
JPEG-2000 yes
JPEG yes
Little CMS yes
Loadable Modules no
Solaris mtmalloc no
OpenMP yes (201307)
PNG yes
TIFF yes
TRIO no
Solaris umem no
WebP yes
WMF yes
X11 yes
XML yes
ZLIB yes
Host type: x86_64-pc-linux-gnu
Configured using the command:
./configure 'CFLAGS=-g -fsanitize=address' '--enable-shared=no'
Final Build Parameters:
CC = gcc
CFLAGS = -fopenmp -g -fsanitize=address -Wall -pthread
CPPFLAGS = -I/usr/include/freetype2 -I/usr/include/libxml2
CXX = g++
CXXFLAGS = -pthread
LDFLAGS =
LIBS = -ljbig -lwebp -lwebpmux -llcms2 -ltiff -lfreetype -ljasper -ljpeg -lpng12 -lwmflite -lXext -lSM -lICE -lX11 -llzma -lbz2 -lxml2 -lz -lm -lpthread
Diff:
This problem is fixed by Mercurial changeset 15945:a348d9661019. Thanks for the report!
Note that the problem text described this issue as a buffer overflow, but the subject was correct that there was only a memory leak.