- 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);