mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-27 15:25:54 -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;
|
||||
}
|
||||
|
||||
buf = (unsigned char*) malloc( bytesperrow );
|
||||
buf = (unsigned char*) alloca( bytesperrow );
|
||||
if ( buf == nullptr ) {
|
||||
pnmimage_tiff_cat.error()
|
||||
<< "Can't allocate memory for row buffer\n";
|
||||
@ -1147,6 +1147,9 @@ write_data(xel *array, xelval *alpha) {
|
||||
pnmimage_tiff_cat.error()
|
||||
<< "Internal error: color not found?!? row=" << row
|
||||
<< " col=" << col << "\n";
|
||||
if (cht != nullptr) {
|
||||
ppm_freecolorhash(cht);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*tP++ = (unsigned char) s;
|
||||
@ -1190,6 +1193,10 @@ write_data(xel *array, xelval *alpha) {
|
||||
TIFFFlushData( tif );
|
||||
TIFFClose( tif );
|
||||
|
||||
if (cht != nullptr) {
|
||||
ppm_freecolorhash(cht);
|
||||
}
|
||||
|
||||
return _y_size;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user