X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8414a40c52191d4c7cfeea74df22d9d64cbec415..3287f62ad3bd6dfcc78a8fcef0ac44d9ece904af:/src/tiff/tools/tiffgt.c diff --git a/src/tiff/tools/tiffgt.c b/src/tiff/tools/tiffgt.c index 835295a0f7..94de892743 100644 --- a/src/tiff/tools/tiffgt.c +++ b/src/tiff/tools/tiffgt.c @@ -1,4 +1,3 @@ -/* $Id$ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -40,6 +39,7 @@ #endif #include "tiffio.h" +#include "tiffiop.h" #ifndef HAVE_GETOPT extern int getopt(int, char**, char*); @@ -204,7 +204,7 @@ initImage(void) if (photo != (uint16) -1) TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photo); if (!TIFFRGBAImageBegin(&img, tif, stoponerr, title)) { - TIFFError(filelist[fileindex], title); + TIFFError(filelist[fileindex], "%s", title); TIFFClose(tif); tif = NULL; return -1; @@ -224,21 +224,24 @@ initImage(void) w = xmax; } - if (w != width || h != height) { - if (raster != NULL) - _TIFFfree(raster), raster = NULL; - raster = (uint32*) _TIFFmalloc(img.width * img.height * sizeof (uint32)); - if (raster == NULL) { - width = height = 0; - TIFFError(filelist[fileindex], "No space for raster buffer"); - cleanup_and_exit(); - } - width = w; - height = h; - } - TIFFRGBAImageGet(&img, raster, img.width, img.height); + if (w != width || h != height) { + uint32 rastersize = + _TIFFMultiply32(tif, img.width, img.height, "allocating raster buffer"); + if (raster != NULL) + _TIFFfree(raster), raster = NULL; + raster = (uint32*) _TIFFCheckMalloc(tif, rastersize, sizeof (uint32), + "allocating raster buffer"); + if (raster == NULL) { + width = height = 0; + TIFFError(filelist[fileindex], "No space for raster buffer"); + cleanup_and_exit(); + } + width = w; + height = h; + } + TIFFRGBAImageGet(&img, raster, img.width, img.height); #if HOST_BIGENDIAN - TIFFSwabArrayOfLong(raster,img.width*img.height); + TIFFSwabArrayOfLong(raster,img.width*img.height); #endif return 0; } @@ -453,3 +456,10 @@ photoArg(const char* arg) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */