summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2023-02-03 17:46:26 +0000
committerEven Rouault <even.rouault@spatialys.com>2023-02-03 17:46:26 +0000
commitf171d7a2cd50e34975036748a395c156d32d9235 (patch)
treefc72894b0de5961014e7032b8d60d1d48d9a5957
parenta63e18ca432e1ee4761309a53019e32bcc446b1d (diff)
parentd63de61b1ec3385f6383ef9a1f453e4b8b11d536 (diff)
downloadlibtiff-git-f171d7a2cd50e34975036748a395c156d32d9235.tar.gz
Merge branch 'TiffClose_NULL_ptr_dereferencing_fix_515' into 'master'
TIFFClose() avoid NULL pointer dereferencing. fix#515 Closes #515 See merge request libtiff/libtiff!468
-rw-r--r--libtiff/tif_close.c11
-rw-r--r--tools/tiffcrop.c5
2 files changed, 11 insertions, 5 deletions
diff --git a/libtiff/tif_close.c b/libtiff/tif_close.c
index 985d290c..907d7f13 100644
--- a/libtiff/tif_close.c
+++ b/libtiff/tif_close.c
@@ -147,9 +147,12 @@ void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif)
void TIFFClose(TIFF *tif)
{
- TIFFCloseProc closeproc = tif->tif_closeproc;
- thandle_t fd = tif->tif_clientdata;
+ if (tif != NULL)
+ {
+ TIFFCloseProc closeproc = tif->tif_closeproc;
+ thandle_t fd = tif->tif_clientdata;
- TIFFCleanup(tif);
- (void)(*closeproc)(fd);
+ TIFFCleanup(tif);
+ (void)(*closeproc)(fd);
+ }
}
diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
index 7db69883..84e26ac6 100644
--- a/tools/tiffcrop.c
+++ b/tools/tiffcrop.c
@@ -2920,7 +2920,10 @@ int main(int argc, char *argv[])
}
}
- TIFFClose(out);
+ if (out != NULL)
+ {
+ TIFFClose(out);
+ }
return (0);
} /* end main */