libtiff: regress old 'fix' that was resulting in strips sometimes not being written (#2088)

https://github.com/libsdl-org/libtiff/commit/4f6ce9f7698dd940978fc8e43935d741a432517a

From 4f6ce9f7698dd940978fc8e43935d741a432517a Mon Sep 17 00:00:00 2001
From: Frank Warmerdam <[EMAIL REDACTED]>
Date: Fri, 28 Aug 2009 17:24:56 +0000
Subject: [PATCH] regress old 'fix' that was resulting in strips sometimes not
 being written (#2088)

---
 ChangeLog              |  6 ++++++
 libtiff/tif_dirwrite.c | 11 +++--------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f870a311..cd3ac85e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-28  Frank Warmerdam  <warmerdam@pobox.com>
+
+	* libtiff/tif_dirwrite.c: Back out changes from 2007-11-22 that
+	resulted in the final strip not being written in some circumstances.
+	http://bugzilla.maptools.org/show_bug.cgi?id=2088
+
 2009-08-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
 	* libtiff/tif_write.c (TIFFAppendToStrip): Remove cast which
diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
index 4a8fa3b8..d5873dec 100644
--- a/libtiff/tif_dirwrite.c
+++ b/libtiff/tif_dirwrite.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dirwrite.c,v 1.37.2.4 2008-05-25 01:55:38 fwarmerdam Exp $ */
+/* $Id: tif_dirwrite.c,v 1.37.2.5 2009-08-28 17:24:56 fwarmerdam Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -100,8 +100,6 @@ _TIFFWriteDirectory(TIFF* tif, int done)
 	 */
 	if (done)
 	{
-                tsize_t orig_rawcc = tif->tif_rawcc;
-
 		if (tif->tif_flags & TIFF_POSTENCODE) {
 			tif->tif_flags &= ~TIFF_POSTENCODE;
 			if (!(*tif->tif_postencode)(tif)) {
@@ -114,12 +112,9 @@ _TIFFWriteDirectory(TIFF* tif, int done)
 		(*tif->tif_close)(tif);		/* shutdown encoder */
 		/*
 		 * Flush any data that might have been written
- 		 * by the compression close+cleanup routines.  But
-                 * be careful not to write stuff if we didn't add data
-                 * in the previous steps as the "rawcc" data may well be
-                 * a previously read tile/strip in mixed read/write mode.
+ 		 * by the compression close+cleanup routines.
 		 */
-		if (tif->tif_rawcc > 0 && tif->tif_rawcc != orig_rawcc
+		if (tif->tif_rawcc > 0
                     && (tif->tif_flags & TIFF_BEENWRITING) != 0
                     && !TIFFFlushData1(tif)) {
 			TIFFErrorExt(tif->tif_clientdata, tif->tif_name,