https://github.com/libsdl-org/libtiff/commit/790ee59d389a36495ebccadd9a1a473c3a44604c
From 47a5279c0a56d957ed33956647699227b59461ac Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Sat, 19 Feb 2022 16:41:09 +0100
Subject: [PATCH] TIFFClientOpen(): remove useless initializations of tif_rawcc
and tif_flags after TIFFReadDirectory()
Those initializations date back to the initial commit of libtiff, but I
strongly suspect there are no longer needed those days.
Setting tif_rawcc to (tmsize_t)-1 is weird. AFAICS, nowhere else in the library
-1 is used as a special markeri for that field. Immediately after TIFFReadDirectory()
returns it is set to 0, and this is the value used in tif_read.c/tif_write.c to
reset it.
And setting the TIFF_BUFFERSETUP bit of tif_flags is even more
suspicious as the only place where it is set otherwise is in
TIFFWriteBufferSetup(). I suspect this bogus setting of the flag was the
reason for commit dbf2339a1 where BUFFERCHECK() in addition to checking
the bit also checked the tif_rawdata against nullptr.
If setting those 2 fields was needed, it would mean that TIFFClientOpen() with the
'h' hint to disable automatic TIFFReadDirectory() would be broken,
because someone issuing a manual TIFFReadDirectory() couldn't set them,
as being private members.
The libtiff test suite is happy with that change, and the GDAL one too.
---
libtiff/tif_open.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c
index 7e4b8f35..a94b68e4 100644
--- a/libtiff/tif_open.c
+++ b/libtiff/tif_open.c
@@ -482,8 +482,6 @@ TIFFClientOpen(
* Setup initial directory.
*/
if (TIFFReadDirectory(tif)) {
- tif->tif_rawcc = (tmsize_t)-1;
- tif->tif_flags |= TIFF_BUFFERSETUP;
return (tif);
}
break;