Page 1 of 1

Magick++ Memory Leak with Corrupted JPEG Files

Posted: 2008-04-08T05:54:53-07:00
by zeugman
I found memory leak in reading some jpeg files.
Valgrind output :

Code: Select all

==6353==    at 0x4A1B95B: realloc (vg_replace_malloc.c:306)
==6353==    by 0x51952E7: ResizeMagickMemory (memory.c:775)
==6353==    by 0x51F6B4E: ParseProcessingInstructions (xml-tree.c:1471)
==6353==    by 0x51F9EBF: NewXMLTree (xml-tree.c:2029)
==6353==    by 0x51A80F3: GetImageProperty (property.c:1414)
==6353==    by 0x51AA416: SetImageProfile (profile.c:1238)
==6353==    by 0x6EF88BA: ReadProfile (jpeg.c:566)
==6353==    by 0x68E42DD: (within /usr/lib/libjpeg.so.62.0.0)
==6353==    by 0x68E2C4D: (within /usr/lib/libjpeg.so.62.0.0)
==6353==    by 0x68E12B5: jpeg_consume_input (in /usr/lib/libjpeg.so.62.0.0)
==6353==    by 0x68E1522: jpeg_read_header (in /usr/lib/libjpeg.so.62.0.0)
==6353==    by 0x6EFAF3C: ReadJPEGImage (jpeg.c:722)
Example of Code :

Code: Select all

#include <Magick++.h>
#include <string> 
#include <iostream>
#include <fstream>
using namespace std;
using namespace Magick;

int main(){
	Image * image;
	image = new Image("MENUsouris-naked.JPG");
	cout << "Width :" << image->baseColumns() << std::endl;
        cout << "Height :" << image->baseRows() << std::endl;
	delete image;
    return EXIT_SUCCESS;
}
Example of image file which causes this memory leak : http://creche.lasourisverte.free.fr/MEN ... -naked.JPG