From 3cdfaeafb15963ad415b8ee34ecce79a9e0121d1 Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Thu, 23 Feb 2006 15:56:34 +0000 Subject: [PATCH] Properly read TIFFTAG_PAGENUMBER, TIFFTAG_HALFTONEHINTS, TIFFTAG_YCBCRSUBSAMPLING and TIFFTAG_DOTRANGE tags as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1088. --- libtiff/tif_print.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c index 0c23c1ce..8352fe78 100644 --- a/libtiff/tif_print.c +++ b/libtiff/tif_print.c @@ -1,4 +1,4 @@ -/* $Id: tif_print.c,v 1.33 2005-12-24 15:36:16 dron Exp $ */ +/* $Id: tif_print.c,v 1.34 2006-02-23 15:56:34 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -528,14 +528,21 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) value_count = td->td_samplesperpixel; else value_count = fip->field_readcount; - if (fip->field_type == TIFF_ASCII - || fip->field_readcount == TIFF_VARIABLE - || fip->field_readcount == TIFF_VARIABLE2 - || fip->field_readcount == TIFF_SPP - || value_count > 1) { + if ((fip->field_type == TIFF_ASCII + || fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2 + || fip->field_readcount == TIFF_SPP + || value_count > 1) + && fip->field_tag != TIFFTAG_PAGENUMBER + && fip->field_tag != TIFFTAG_HALFTONEHINTS + && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING + && fip->field_tag != TIFFTAG_DOTRANGE) { if(TIFFGetField(tif, tag, &raw_data) != 1) continue; - } else { + } else if (fip->field_tag != TIFFTAG_PAGENUMBER + && fip->field_tag != TIFFTAG_HALFTONEHINTS + && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING + && fip->field_tag != TIFFTAG_DOTRANGE) { raw_data = _TIFFmalloc( _TIFFDataSize(fip->field_type) * value_count); @@ -544,6 +551,24 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) _TIFFfree(raw_data); continue; } + } else { + /* + * XXX: Should be fixed and removed, see the + * notes related to TIFFTAG_PAGENUMBER, + * TIFFTAG_HALFTONEHINTS, + * TIFFTAG_YCBCRSUBSAMPLING and + * TIFFTAG_DOTRANGE tags in tif_dir.c. */ + char *tmp; + raw_data = _TIFFmalloc( + _TIFFDataSize(fip->field_type) + * value_count); + tmp = raw_data; + mem_alloc = 1; + if(TIFFGetField(tif, tag, tmp, + tmp + _TIFFDataSize(fip->field_type)) != 1) { + _TIFFfree(raw_data); + continue; + } } }