Fix for some memory leaks issue #657

This commit is contained in:
ffsup2
2011-06-07 20:12:01 +02:00
parent c109330c53
commit fbb9cff8ee
9 changed files with 31 additions and 18 deletions

View File

@@ -119,9 +119,9 @@ ImageIO::~ImageIO () {
if (embProfile)
cmsCloseProfile(embProfile);
delete loadedProfileData;
delete [] loadedProfileData;
delete exifRoot;
delete profileData;
delete [] profileData;
}
void png_read_data(png_struct_def *png_ptr, unsigned char *data, size_t length);
@@ -278,9 +278,11 @@ int ImageIO::loadJPEGFromMemory (const char* buffer, int bufsize)
//jpeg_memory_src (&cinfo,buffer,bufsize);
jpeg_read_header(&cinfo, TRUE);
unsigned int proflen;
delete loadedProfileData;
loadedProfileData = NULL;
unsigned int proflen;
if( loadedProfileData ){
delete [] loadedProfileData;
loadedProfileData = NULL;
}
bool hasprofile = read_icc_profile (&cinfo, (JOCTET**)&loadedProfileData, (unsigned int*)&loadedProfileLength);
if (hasprofile)
embProfile = cmsOpenProfileFromMem (loadedProfileData, loadedProfileLength);
@@ -434,8 +436,10 @@ int ImageIO::loadTIFF (Glib::ustring fname) {
}
char* profdata;
delete loadedProfileData;
loadedProfileData = NULL;
if( loadedProfileData ){
delete [] loadedProfileData;
loadedProfileData = NULL;
}
if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &loadedProfileLength, &profdata)) {
embProfile = cmsOpenProfileFromMem (profdata, loadedProfileLength);
loadedProfileData = new char [loadedProfileLength];