2008.12.17 20:54 "[Tiff] Deleting tags from a directory", by Frank Warmerdam

2009.02.26 22:44 "Re: [Tiff] assertions, and building with DEBUG/NDEBUG", by

Frank, folks,

> http://bugzilla.maptools.org/show_bug.cgi?id=1994

There's been no response on my proposed fix, in the mailing list nor on bugzilla. But I need LibTiff to not crash on me, for crosstesting, so I did a quick hack that is even shorter and easier then the fix I proposed before as I realized we don't actually need to sort. We merely have to keep away duplicate tags, for IGNORE to work. So we could simply keep away the duplicates by flagging them IGNORE prior to any other processing. I inserted the following few lines in the TIFFReadDirectory function, in tif_dirread.c, near the top of that function right between the call to TIFFReadDirectoryCheckOrder and the partial resetting of tif->tif_flags.

{
 TIFFDirEntry* ma;
 uint16 mb;
 for (ma=dir, mb=0; mb<dircount; ma++, mb++)
 {
  TIFFDirEntry* na;
  uint16 nb;
  for (na=ma+1, nb=mb+1; nb<dircount; na++, nb++)
  {
   if (ma->tdir_tag==na->tdir_tag)
    na->tdir_tag=IGNORE;
  }
 }
}

That does not just solve this problem, it'll solve all problems with duplicate instances of any special tag, and means the IGNORE mechanism works as intented. Someone with CVS write access please consider this fix.

Best regards,

Joris