bug 843: similar fix to last for Longs and Anys version of function

This commit is contained in:
Frank Warmerdam 2005-05-06 14:35:50 +00:00
parent 30565aceb6
commit 3a6e371160
2 changed files with 65 additions and 51 deletions

View File

@ -1,4 +1,10 @@
2005-05-06 Frank Warmerdam <warmerdam@pobox.com>
* libtiff/tif_dirread.c: Applied similar change to
TIFFFetchPerSampleLongs and TIFFFetchPerSampleAnys.
http://bugzilla.remotesensing.org/show_bug.cgi?id=843
* libtiff/tif_jpeg.c: added LIB_JPEG_MK1 support in JPEGDecodeRaw().
2005-05-06 Andrey Kiselev <dron@remotesensing.org>

View File

@ -1,4 +1,4 @@
/* $Id: tif_dirread.c,v 1.52 2005-05-05 18:03:22 fwarmerdam Exp $ */
/* $Id: tif_dirread.c,v 1.53 2005-05-06 14:35:50 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -1344,33 +1344,37 @@ TIFFFetchPerSampleShorts(TIFF* tif, TIFFDirEntry* dir, uint16* pl)
static int
TIFFFetchPerSampleLongs(TIFF* tif, TIFFDirEntry* dir, uint32* pl)
{
uint16 samples = tif->tif_dir.td_samplesperpixel;
int status = 0;
uint16 samples = tif->tif_dir.td_samplesperpixel;
int status = 0;
if (CheckDirCount(tif, dir, (uint32) samples)) {
uint32 buf[10];
uint32* v = buf;
if (CheckDirCount(tif, dir, (uint32) samples)) {
uint32 buf[10];
uint32* v = buf;
if (samples > NITEMS(buf))
v = (uint32*) CheckMalloc(tif, samples, sizeof(uint32),
"to fetch per-sample values");
if (v && TIFFFetchLongArray(tif, dir, v)) {
uint16 i;
for (i = 1; i < samples; i++)
if (v[i] != v[0]) {
TIFFError(tif->tif_name,
"Cannot handle different per-sample values for field \"%s\"",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
goto bad;
}
*pl = v[0];
status = 1;
}
bad:
if (v && v != buf)
_TIFFfree(v);
}
return (status);
if (dir->tdir_count > NITEMS(buf))
v = (uint32*) CheckMalloc(tif, dir->tdir_count, sizeof(uint32),
"to fetch per-sample values");
if (v && TIFFFetchLongArray(tif, dir, v)) {
uint16 i;
int check_count = dir->tdir_count;
if( samples < check_count )
check_count = samples;
for (i = 1; i < check_count; i++)
if (v[i] != v[0]) {
TIFFError(tif->tif_name,
"Cannot handle different per-sample values for field \"%s\"",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
goto bad;
}
*pl = v[0];
status = 1;
}
bad:
if (v && v != buf)
_TIFFfree(v);
}
return (status);
}
/*
@ -1381,33 +1385,37 @@ TIFFFetchPerSampleLongs(TIFF* tif, TIFFDirEntry* dir, uint32* pl)
static int
TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl)
{
uint16 samples = tif->tif_dir.td_samplesperpixel;
int status = 0;
uint16 samples = tif->tif_dir.td_samplesperpixel;
int status = 0;
if (CheckDirCount(tif, dir, (uint32) samples)) {
double buf[10];
double* v = buf;
if (CheckDirCount(tif, dir, (uint32) samples)) {
double buf[10];
double* v = buf;
if (samples > NITEMS(buf))
v = (double*) CheckMalloc(tif, samples, sizeof (double),
"to fetch per-sample values");
if (v && TIFFFetchAnyArray(tif, dir, v)) {
uint16 i;
for (i = 1; i < samples; i++)
if (v[i] != v[0]) {
TIFFError(tif->tif_name,
"Cannot handle different per-sample values for field \"%s\"",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
goto bad;
}
*pl = v[0];
status = 1;
}
bad:
if (v && v != buf)
_TIFFfree(v);
}
return (status);
if (dir->tdir_count > NITEMS(buf))
v = (double*) CheckMalloc(tif, dir->tdir_count, sizeof (double),
"to fetch per-sample values");
if (v && TIFFFetchAnyArray(tif, dir, v)) {
uint16 i;
int check_count = dir->tdir_count;
if( samples < check_count )
check_count = samples;
for (i = 1; i < check_count; i++)
if (v[i] != v[0]) {
TIFFError(tif->tif_name,
"Cannot handle different per-sample values for field \"%s\"",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
goto bad;
}
*pl = v[0];
status = 1;
}
bad:
if (v && v != buf)
_TIFFfree(v);
}
return (status);
}
#undef NITEMS