From 7e5d9d565941a9355cf091acb18b6b46e0629825 Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Mon, 2 Sep 2002 15:39:45 +0000 Subject: [PATCH] Fixed problem with SBYTE type data fetching in TIFFFetchByteArray(). Problem described in http://bugzilla.remotesensing.org/show_bug.cgi?id=52 --- libtiff/tif_dirread.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index 477e822e..a92b1f9e 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirread.c,v 1.10 2002-04-08 17:07:19 dron Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirread.c,v 1.11 2002-09-02 15:39:45 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -784,14 +784,22 @@ TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) case 4: v[3] = (uint16)(dir->tdir_offset & 0xff); case 3: v[2] = (uint16)((dir->tdir_offset >> 8) & 0xff); case 2: v[1] = (uint16)((dir->tdir_offset >> 16) & 0xff); - case 1: v[0] = (uint16)(dir->tdir_offset >> 24); + case 1: + if (dir->tdir_type == TIFF_SBYTE) + v[0] = (signed char)(dir->tdir_offset >> 24); + else + v[0] = (uint16)(dir->tdir_offset >> 24); } } else { switch (dir->tdir_count) { case 4: v[3] = (uint16)(dir->tdir_offset >> 24); case 3: v[2] = (uint16)((dir->tdir_offset >> 16) & 0xff); case 2: v[1] = (uint16)((dir->tdir_offset >> 8) & 0xff); - case 1: v[0] = (uint16)(dir->tdir_offset & 0xff); + case 1: + if (dir->tdir_type == TIFF_SBYTE) + v[0] = (signed char)((dir->tdir_offset) & 0xff); + else + v[0] = (uint16)(dir->tdir_offset & 0xff); } } return (1);