Fixed crash when reading some TIF files

see issue 1389
This commit is contained in:
Oliver Duis
2012-06-10 18:53:20 +02:00
parent 06e3066c8e
commit 79527e99fb

View File

@@ -439,9 +439,16 @@ int ImageIO::loadTIFF (Glib::ustring fname) {
TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
uint16 bitspersample, samplesperpixel, sampleformat; uint16 bitspersample, samplesperpixel, sampleformat;
TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); int hasTag = TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample);
TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); hasTag &= TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
TIFFGetField(in, TIFFTAG_SAMPLEFORMAT, &sampleformat); if (!hasTag) {
// These are needed
TIFFClose(in);
return IMIO_VARIANTNOTSUPPORTED;
}
hasTag=TIFFGetField(in, TIFFTAG_SAMPLEFORMAT, &sampleformat);
if (!hasTag) sampleformat=0;
uint16 photometric; uint16 photometric;
if (!TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric) || if (!TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric) ||