https://github.com/libsdl-org/libtiff/commit/9281fdd94ec861bc18767c05ea4b578cbdfd752a
From 9281fdd94ec861bc18767c05ea4b578cbdfd752a Mon Sep 17 00:00:00 2001
From: Andrey Kiselev <[EMAIL REDACTED]>
Date: Fri, 2 Jul 2010 13:38:27 +0000
Subject: [PATCH] Avoid wrong math du to the signed/unsigned integer type
conversions. As per bug http://bugzilla.maptools.org/show_bug.cgi?id=2207
---
ChangeLog | 4 ++++
libtiff/tif_getimage.c | 12 +++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 55f8e9b7..ab365435 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2010-07-02 Andrey Kiselev <dron@ak4719.spb.edu>
+ * libtiff/tif_getimage.c: Avoid wrong math du to the signed/unsigned
+ integer type conversions. As per bug
+ http://bugzilla.maptools.org/show_bug.cgi?id=2207
+
* tools/{tiff2bw.c, thumbnail.c, pal2rgb.c}: Fix the count for
WhitePoint tag as per bug
http://bugzilla.maptools.org/show_bug.cgi?id=2042
diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c
index a3ca4328..11d59e06 100644
--- a/libtiff/tif_getimage.c
+++ b/libtiff/tif_getimage.c
@@ -1,4 +1,4 @@
-/* $Id: tif_getimage.c,v 1.63.2.5 2010-07-02 10:03:07 dron Exp $ */
+/* $Id: tif_getimage.c,v 1.63.2.6 2010-07-02 13:38:27 dron Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@@ -1846,6 +1846,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
DECLAREContigPutFunc(putcontig8bitYCbCr22tile)
{
uint32* cp2;
+ int32 incr = 2*toskew+w;
(void) y;
fromskew = (fromskew / 2) * 6;
cp2 = cp+w+toskew;
@@ -1872,8 +1873,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile)
cp2 ++ ;
pp += 6;
}
- cp += toskew*2+w;
- cp2 += toskew*2+w;
+ cp += incr;
+ cp2 += incr;
pp += fromskew;
h-=2;
}
@@ -1939,6 +1940,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
DECLAREContigPutFunc(putcontig8bitYCbCr12tile)
{
uint32* cp2;
+ int32 incr = 2*toskew+w;
(void) y;
fromskew = (fromskew / 2) * 4;
cp2 = cp+w+toskew;
@@ -1953,8 +1955,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr12tile)
cp2 ++;
pp += 4;
} while (--x);
- cp += toskew*2+w;
- cp2 += toskew*2+w;
+ cp += incr;
+ cp2 += incr;
pp += fromskew;
h-=2;
}