mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Ensure that Tiff's concept of Strip and Tilesize matches Pillow's
This commit is contained in:
parent
c7f9e197aa
commit
6b842f4ec0
|
@ -363,6 +363,13 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, Py_
|
||||||
|
|
||||||
state->bytes = row_byte_size * tile_length;
|
state->bytes = row_byte_size * tile_length;
|
||||||
|
|
||||||
|
if (TIFFTileSize(tiff) > state->bytes) {
|
||||||
|
// If the strip size as expected by LibTiff isn't we're expecting, abort.
|
||||||
|
state->errcode = IMAGING_CODEC_MEMORY;
|
||||||
|
TIFFClose(tiff);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* realloc to fit whole tile */
|
/* realloc to fit whole tile */
|
||||||
/* malloc check above */
|
/* malloc check above */
|
||||||
new_data = realloc (state->buffer, state->bytes);
|
new_data = realloc (state->buffer, state->bytes);
|
||||||
|
@ -424,11 +431,21 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, Py_
|
||||||
TIFFClose(tiff);
|
TIFFClose(tiff);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->bytes = rows_per_strip * row_byte_size;
|
state->bytes = rows_per_strip * row_byte_size;
|
||||||
|
|
||||||
TRACE(("StripSize: %d \n", state->bytes));
|
TRACE(("StripSize: %d \n", state->bytes));
|
||||||
|
|
||||||
|
if (TIFFStripSize(tiff) > state->bytes) {
|
||||||
|
// If the strip size as expected by LibTiff isn't we're expecting, abort.
|
||||||
|
// man: TIFFStripSize returns the equivalent size for a strip of data as it would be returned in a
|
||||||
|
// call to TIFFReadEncodedStrip ...
|
||||||
|
|
||||||
|
state->errcode = IMAGING_CODEC_MEMORY;
|
||||||
|
TIFFClose(tiff);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* realloc to fit whole strip */
|
/* realloc to fit whole strip */
|
||||||
/* malloc check above */
|
/* malloc check above */
|
||||||
new_data = realloc (state->buffer, state->bytes);
|
new_data = realloc (state->buffer, state->bytes);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user