From 47656ccb3f5847b5236c7fa236a0d8928fc50ce0 Mon Sep 17 00:00:00 2001 From: Bug Checkers Date: Mon, 4 Nov 2019 21:14:38 +0000 Subject: [PATCH] adds missing checks on TIFFGetField in tiffcrop tool (fixes #170) --- tools/tiffcrop.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c index 7b3c9e78..29c19a2f 100644 --- a/tools/tiffcrop.c +++ b/tools/tiffcrop.c @@ -1334,9 +1334,10 @@ static int writeBufferToSeparateTiles (TIFF* out, uint8* buf, uint32 imagelength if (obuf == NULL) return 1; - TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); - TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps); + if( !TIFFGetField(out, TIFFTAG_TILELENGTH, &tl) || + !TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw) || + !TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps) ) + return 1; if( imagewidth == 0 || (uint32)bps * (uint32)spp > TIFF_UINT32_MAX / imagewidth ||