[libGD] #185 [Task opened] memory leaks in XpmReadFileToXpmImage()

[email protected] Wed, 26 Nov 2008 19:03:45 +0100 (CET)
Newsgroups php.gd.bugs
Message-ID <[email protected]>
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

A new Flyspray task has been opened.  Details are below. 

User who did this - Takeshi Abe (Takeshi) 

Attached to Project - libGD
Summary - memory leaks in XpmReadFileToXpmImage() 
Task Type - Bug Report
Category - Image Import/Export
Status - Assigned
Assigned To - Takeshi Abe
Operating System - All
Severity - Medium
Priority - Normal
Reported Version - 2.0.35
Due in Version - 2.0.36
Due Date - Undecided
Details - As Brian Peschel reported in gd-devel;

the following function results in memleaks:
<code>
void XpmImageConverter::getImageDimensions()
{
    gdImagePtr image;
    char tmpFilename[_fname.length() + 1];

    // GD doesn't like const pointers :(
    strcpy(tmpFilename, _fname.c_str());
    if ((image = gdImageCreateFromXpm(tmpFilename)) == NULL)
    {
     	std::cerr << "Failed to open jpeg file \"" << _fname << "\"" << std::endl;
	return;
    }

    imageWidth = gdImageSX(image);
    imageHeight = gdImageSY(image);

    gdImageDestroy(image);
}
</code>

According to Valgrind, this is leaking a lot of memory (for small images, largest is 48x48 pixels, most are 24x24 pixels):
<code>
==16200== 32,731,968 bytes in 33 blocks are possibly lost in loss record 744 of 744
==16200==    at 0x4005525: malloc (vg_replace_malloc.c:149)
==16200==    by 0xD9067A: xpmParseData (in /usr/lib/libXpm.so.4.11.0)
==16200==    by 0xD893B9: XpmReadFileToXpmImage (in /usr/lib/libXpm.so.4.11.0)
==16200==    by 0x80CBED5: gdImageCreateFromXpm (in )
==16200==    by 0x437E45F: XpmImageConverter::getImageDimensions() ()
</code>

This is on Fedora 8, gcc 4.1.2-33, gd 2.0.35, and libXpm 3.5.7.


More information can be found at the following URL:
http://bugs.libgd.org/?do=details&task_id=185

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.