diff options
Diffstat (limited to 'source/blender/imbuf/intern/tiff.c')
-rw-r--r-- | source/blender/imbuf/intern/tiff.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index cd0b012d809..587d6ad9e7e 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -316,10 +316,13 @@ static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, const unsigned char * * hence my manual comparison. - Jonathan Merritt (lancelet) 4th Sept 2005. */ #define IMB_TIFF_NCB 4 /* number of comparison bytes used */ -int imb_is_a_tiff(const unsigned char *buf) +bool imb_is_a_tiff(const unsigned char *buf, size_t size) { const char big_endian[IMB_TIFF_NCB] = {0x4d, 0x4d, 0x00, 0x2a}; const char lil_endian[IMB_TIFF_NCB] = {0x49, 0x49, 0x2a, 0x00}; + if (size < IMB_TIFF_NCB) { + return false; + } return ((memcmp(big_endian, buf, IMB_TIFF_NCB) == 0) || (memcmp(lil_endian, buf, IMB_TIFF_NCB) == 0)); @@ -578,7 +581,7 @@ ImBuf *imb_loadtiff(const unsigned char *mem, fprintf(stderr, "imb_loadtiff: size < IMB_TIFF_NCB\n"); return NULL; } - if (imb_is_a_tiff(mem) == 0) { + if (imb_is_a_tiff(mem, size) == 0) { return NULL; } @@ -759,8 +762,7 @@ void imb_loadtiletiff( * * \return 1 if the function is successful, 0 on failure. */ - -int imb_savetiff(ImBuf *ibuf, const char *filepath, int flags) +bool imb_savetiff(ImBuf *ibuf, const char *filepath, int flags) { TIFF *image = NULL; uint16 samplesperpixel, bitspersample; @@ -888,7 +890,7 @@ int imb_savetiff(ImBuf *ibuf, const char *filepath, int flags) /* convert from float source */ float rgb[4]; - if (channels_in_float == 3 || channels_in_float == 4) { + if (ELEM(channels_in_float, 3, 4)) { if (ibuf->float_colorspace || (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) { /* Float buffer was managed already, no need in color * space conversion. |