diff --git a/src/libImaging/TiffDecode.c b/src/libImaging/TiffDecode.c index 9361de834..35122f182 100644 --- a/src/libImaging/TiffDecode.c +++ b/src/libImaging/TiffDecode.c @@ -720,9 +720,14 @@ ImagingLibTiffDecode( } decode_err: + // TIFFClose in libtiff calls tif_closeproc and TIFFCleanup if (clientstate->fp) { + // Pillow will manage the closing of the file rather than libtiff + // So only call TIFFCleanup TIFFCleanup(tiff); } else { + // When tif_closeproc refers to our custom _tiffCloseProc though, + // that is fine, as it does not close the file TIFFClose(tiff); } TRACE(("Done Decoding, Returning \n"));