fix [#36089] crash when using a tiff without TIFFTAG_EXTRASAMPLES

This commit is contained in:
Campbell Barton
2013-07-11 04:38:47 +00:00
parent 7fec23ae0a
commit b035ce3a82

View File

@@ -532,6 +532,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[
int level;
short spp;
int ib_depth;
int found;
/* check whether or not we have a TIFF file */
if (size < IMB_TIFF_NCB) {
@@ -575,10 +576,11 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[
if (spp == 4) {
unsigned short extra, *extraSampleTypes;
TIFFGetField(image, TIFFTAG_EXTRASAMPLES, &extra, &extraSampleTypes);
found = TIFFGetField(image, TIFFTAG_EXTRASAMPLES, &extra, &extraSampleTypes);
if (extraSampleTypes[0] == EXTRASAMPLE_ASSOCALPHA)
if (found && (extraSampleTypes[0] == EXTRASAMPLE_ASSOCALPHA)) {
ibuf->flags |= IB_alphamode_premul;
}
}
}