summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libtiff/libtiff/tif_close.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/libtiff/libtiff/tif_close.c')
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_close.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/3rdparty/libtiff/libtiff/tif_close.c b/src/3rdparty/libtiff/libtiff/tif_close.c
index 674518a..04977bc 100644
--- a/src/3rdparty/libtiff/libtiff/tif_close.c
+++ b/src/3rdparty/libtiff/libtiff/tif_close.c
@@ -80,10 +80,15 @@ TIFFCleanup(TIFF* tif)
for (i = 0; i < tif->tif_nfields; i++) {
TIFFField *fld = tif->tif_fields[i];
- if (fld->field_bit == FIELD_CUSTOM &&
- strncmp("Tag ", fld->field_name, 4) == 0) {
- _TIFFfree(fld->field_name);
- _TIFFfree(fld);
+ if (fld->field_name != NULL) {
+ if (fld->field_bit == FIELD_CUSTOM &&
+ /* caution: tif_fields[i] must not be the beginning of a fields-array.
+ * Otherwise the following tags are also freed with the first free().
+ */
+ TIFFFieldIsAnonymous(fld)) {
+ _TIFFfree(fld->field_name);
+ _TIFFfree(fld);
+ }
}
}