From 079423f5c5e22faaaa5db9b590f09ee111db5d47 Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 20 Dec 2012 22:33:52 -0800 Subject: [PATCH] tiffdec: check error returns for width/height Change-Id: I1399a7b75aea54044f30c6a53ac11843c1e75877 --- examples/tiffdec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/tiffdec.c b/examples/tiffdec.c index c93be49a..9f2d4214 100644 --- a/examples/tiffdec.c +++ b/examples/tiffdec.c @@ -41,8 +41,11 @@ int ReadTIFF(const char* const filename, dircount - 1); } - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); + if (!(TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width) && + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height))) { + fprintf(stderr, "Error! Cannot retrieve TIFF image dimensions.\n"); + return 0; + } raster = (uint32*)_TIFFmalloc(width * height * sizeof(*raster)); if (raster != NULL) { if (TIFFReadRGBAImageOriented(tif, width, height, raster,