From 1ed16b4290c6ec05ca0b70b1b98af7bcbc968124 Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Thu, 22 Aug 2002 18:31:40 +0000 Subject: [PATCH] Further additions to free custom fields in _TIFFSetupFieldInfo() function. See http://bugzilla.remotesensing.org/show_bug.cgi?id=169 for details. --- libtiff/tif_dirinfo.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c index 5a815c1d..fe6fbb92 100644 --- a/libtiff/tif_dirinfo.c +++ b/libtiff/tif_dirinfo.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirinfo.c,v 1.18 2002-08-15 12:59:50 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirinfo.c,v 1.19 2002-08-22 18:31:40 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -280,6 +280,19 @@ void _TIFFSetupFieldInfo(TIFF* tif) { if (tif->tif_fieldinfo) { + int i; + + for (i = 0; i < tif->tif_nfields; i++) + { + TIFFFieldInfo *fld = tif->tif_fieldinfo[i]; + if (fld->field_bit == FIELD_CUSTOM && + strncmp("Tag ", fld->field_name, 4) == 0) + { + _TIFFfree(fld->field_name); + _TIFFfree(fld); + } + } + _TIFFfree(tif->tif_fieldinfo); tif->tif_nfields = 0; } @@ -464,7 +477,9 @@ _TIFFCreateAnonFieldInfo(TIFF *tif, ttag_t tag, TIFFDataType field_type) fld->field_passcount = TRUE; fld->field_name = (char *) _TIFFmalloc(32); - /* note that this name is a special sign to TIFFClose() to free the field*/ + /* note that this name is a special sign to TIFFClose() and + * _TIFFSetupFieldInfo() to free the field + */ sprintf(fld->field_name, "Tag %d", (int) tag); return fld;