Check for JPEGTables tag presence before copying.

This commit is contained in:
Andrey Kiselev 2005-05-17 14:18:48 +00:00
parent 3a6e371160
commit 53fb873cc2

View File

@ -1,4 +1,4 @@
/* $Id: tiffsplit.c,v 1.9 2004-06-05 08:11:26 dron Exp $ */ /* $Id: tiffsplit.c,v 1.10 2005-05-17 14:18:48 dron Exp $ */
/* /*
* Copyright (c) 1992-1997 Sam Leffler * Copyright (c) 1992-1997 Sam Leffler
@ -151,11 +151,13 @@ tiffcp(TIFF* in, TIFF* out)
CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
CopyField(TIFFTAG_COMPRESSION, compression); CopyField(TIFFTAG_COMPRESSION, compression);
if (compression == COMPRESSION_JPEG) { if (compression == COMPRESSION_JPEG) {
uint16 count; uint16 count = 0;
void *table; void *table = NULL;
TIFFGetField(in, TIFFTAG_JPEGTABLES, &count, &table); if (TIFFGetField(in, TIFFTAG_JPEGTABLES, &count, &table)
&& count > 0 && table) {
TIFFSetField(out, TIFFTAG_JPEGTABLES, count, table); TIFFSetField(out, TIFFTAG_JPEGTABLES, count, table);
} }
}
CopyField(TIFFTAG_PHOTOMETRIC, shortv); CopyField(TIFFTAG_PHOTOMETRIC, shortv);
CopyField(TIFFTAG_PREDICTOR, shortv); CopyField(TIFFTAG_PREDICTOR, shortv);
CopyField(TIFFTAG_THRESHHOLDING, shortv); CopyField(TIFFTAG_THRESHHOLDING, shortv);