Lines 261-267
bool wxTIFFHandler::LoadFile( wxImage *i
Link Here
|
261 |
} |
261 |
} |
262 |
|
262 |
|
263 |
uint32 w, h; |
263 |
uint32 w, h; |
264 |
uint32 npixels; |
|
|
265 |
uint32 *raster; |
264 |
uint32 *raster; |
266 |
|
265 |
|
267 |
TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &w ); |
266 |
TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &w ); |
Lines 275-283
bool wxTIFFHandler::LoadFile( wxImage *i
Link Here
|
275 |
(samplesInfo[0] == EXTRASAMPLE_ASSOCALPHA || |
274 |
(samplesInfo[0] == EXTRASAMPLE_ASSOCALPHA || |
276 |
samplesInfo[0] == EXTRASAMPLE_UNASSALPHA)); |
275 |
samplesInfo[0] == EXTRASAMPLE_UNASSALPHA)); |
277 |
|
276 |
|
278 |
npixels = w * h; |
277 |
// guard against integer overflow during multiplication which could result |
|
|
278 |
// in allocating a too small buffer and then overflowing it |
279 |
const double bytesNeeded = (double)w * (double)h * sizeof(uint32); |
280 |
if ( bytesNeeded >= 4294967295U /* UINT32_MAX */ ) |
281 |
{ |
282 |
if ( verbose ) |
283 |
wxLogError( _("TIFF: Image size is abnormally big.") ); |
284 |
|
285 |
TIFFClose(tif); |
286 |
|
287 |
return false; |
288 |
} |
279 |
|
289 |
|
280 |
raster = (uint32*) _TIFFmalloc( npixels * sizeof(uint32) ); |
290 |
raster = (uint32*) _TIFFmalloc( bytesNeeded ); |
281 |
|
291 |
|
282 |
if (!raster) |
292 |
if (!raster) |
283 |
{ |
293 |
{ |