mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 00:06:44 -04:00
pnmimagetypes: Fix memory leaks writing TIFF files
This commit is contained in:
parent
718bac1c69
commit
3d7c2505e9
@ -1076,7 +1076,7 @@ write_data(xel *array, xelval *alpha) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = (unsigned char*) malloc( bytesperrow );
|
buf = (unsigned char*) alloca( bytesperrow );
|
||||||
if ( buf == nullptr ) {
|
if ( buf == nullptr ) {
|
||||||
pnmimage_tiff_cat.error()
|
pnmimage_tiff_cat.error()
|
||||||
<< "Can't allocate memory for row buffer\n";
|
<< "Can't allocate memory for row buffer\n";
|
||||||
@ -1147,6 +1147,9 @@ write_data(xel *array, xelval *alpha) {
|
|||||||
pnmimage_tiff_cat.error()
|
pnmimage_tiff_cat.error()
|
||||||
<< "Internal error: color not found?!? row=" << row
|
<< "Internal error: color not found?!? row=" << row
|
||||||
<< " col=" << col << "\n";
|
<< " col=" << col << "\n";
|
||||||
|
if (cht != nullptr) {
|
||||||
|
ppm_freecolorhash(cht);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*tP++ = (unsigned char) s;
|
*tP++ = (unsigned char) s;
|
||||||
@ -1190,6 +1193,10 @@ write_data(xel *array, xelval *alpha) {
|
|||||||
TIFFFlushData( tif );
|
TIFFFlushData( tif );
|
||||||
TIFFClose( tif );
|
TIFFClose( tif );
|
||||||
|
|
||||||
|
if (cht != nullptr) {
|
||||||
|
ppm_freecolorhash(cht);
|
||||||
|
}
|
||||||
|
|
||||||
return _y_size;
|
return _y_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user