commit 26d8e9052f2226508d076f390162afb04d737bec Author: erouault Date: Sat Dec 27 15:20:42 2014 +0000 * libtiff/tif_dir.c: in TIFFDefaultDirectory(), reset any already existing extented tags installed by user code through the extender mechaninm before calling the extender callback (GDAL #5054) diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c index ab43a28..1a413df 100644 --- a/libtiff/tif_dir.c +++ b/libtiff/tif_dir.c @@ -1322,8 +1322,20 @@ TIFFDefaultDirectory(TIFF* tif) tif->tif_tagmethods.printdir = NULL; /* * Give client code a chance to install their own - * tag extensions & methods, prior to compression overloads. + * tag extensions & methods, prior to compression overloads, + * but do some prior cleanup first. (http://trac.osgeo.org/gdal/ticket/5054) */ + if (tif->tif_nfieldscompat > 0) { + uint32 i; + + for (i = 0; i < tif->tif_nfieldscompat; i++) { + if (tif->tif_fieldscompat[i].allocated_size) + _TIFFfree(tif->tif_fieldscompat[i].fields); + } + _TIFFfree(tif->tif_fieldscompat); + tif->tif_nfieldscompat = 0; + tif->tif_fieldscompat = NULL; + } if (_TIFFextender) (*_TIFFextender)(tif); (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);