forked from bartvdbraak/blender
Fix for tiff 16bit saving commit, had memory leak.
This commit is contained in:
parent
d5773b5c64
commit
59195b3e18
@ -312,7 +312,7 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
|
||||
struct ImBuf *ibuf = NULL;
|
||||
struct ImbTIFFMemFile memFile;
|
||||
uint32 width, height;
|
||||
int bytesperpixel;
|
||||
int bytesperpixel, bitspersample;
|
||||
int success;
|
||||
unsigned int pixel_i, byte_i;
|
||||
uint32 *raster = NULL;
|
||||
@ -346,6 +346,7 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
|
||||
bytesperpixel = 4; /* 1 byte per channel, 4 channels */
|
||||
libtiff_TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width);
|
||||
libtiff_TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height);
|
||||
libtiff_TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bitspersample);
|
||||
ibuf = IMB_allocImBuf(width, height, 8*bytesperpixel, 0, 0);
|
||||
if (ibuf) {
|
||||
ibuf->ftype = TIF;
|
||||
@ -562,13 +563,15 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags)
|
||||
fprintf(stderr,
|
||||
"imb_savetiff: Could not write encoded TIFF.\n");
|
||||
libtiff_TIFFClose(image);
|
||||
libtiff__TIFFfree(pixels);
|
||||
if(pixels) libtiff__TIFFfree(pixels);
|
||||
if(pixels16) libtiff__TIFFfree(pixels16);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* close the TIFF file */
|
||||
libtiff_TIFFClose(image);
|
||||
libtiff__TIFFfree(pixels);
|
||||
if(pixels) libtiff__TIFFfree(pixels);
|
||||
if(pixels16) libtiff__TIFFfree(pixels16);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user