move variable declaration

This commit is contained in:
Konstantin Kopachev 2018-07-17 12:33:52 -07:00
parent e102f4848b
commit c2ac4604bc
No known key found for this signature in database
GPG Key ID: CECF757E656F4F62

View File

@ -55,7 +55,7 @@ tsize_t _tiffWriteProc(thandle_t hdata, tdata_t buf, tsize_t size) {
to_write = min(size, state->size - (tsize_t)state->loc); to_write = min(size, state->size - (tsize_t)state->loc);
if (state->flrealloc && size>to_write) { if (state->flrealloc && size>to_write) {
tdata_t new; tdata_t new_data;
tsize_t newsize=state->size; tsize_t newsize=state->size;
while (newsize < (size + state->size)) { while (newsize < (size + state->size)) {
if (newsize > INT_MAX - 64*1024){ if (newsize > INT_MAX - 64*1024){
@ -66,12 +66,12 @@ tsize_t _tiffWriteProc(thandle_t hdata, tdata_t buf, tsize_t size) {
} }
TRACE(("Reallocing in write to %d bytes\n", (int)newsize)); TRACE(("Reallocing in write to %d bytes\n", (int)newsize));
/* malloc check ok, overflow checked above */ /* malloc check ok, overflow checked above */
new = realloc(state->data, newsize); new_data = realloc(state->data, newsize);
if (!new) { if (!new_data) {
// fail out // fail out
return 0; return 0;
} }
state->data = new; state->data = new_data;
state->size = newsize; state->size = newsize;
to_write = size; to_write = size;
} }
@ -237,6 +237,10 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, int
TIFFSetField(tiff, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); TIFFSetField(tiff, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
if (TIFFIsTiled(tiff)) { if (TIFFIsTiled(tiff)) {
uint32 x, y, tile_y;
uint32 tileWidth, tileLength;
UINT8 *new_data;
state->bytes = TIFFTileSize(tiff); state->bytes = TIFFTileSize(tiff);
/* overflow check for malloc */ /* overflow check for malloc */
@ -247,20 +251,17 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, int
} }
/* realloc to fit whole tile */ /* realloc to fit whole tile */
UINT8 *new = realloc (state->buffer, state->bytes); new_data = realloc (state->buffer, state->bytes);
if (!new) { if (!new_data) {
state->errcode = IMAGING_CODEC_MEMORY; state->errcode = IMAGING_CODEC_MEMORY;
TIFFClose(tiff); TIFFClose(tiff);
return -1; return -1;
} }
state->buffer = new; state->buffer = new_data;
TRACE(("TIFFTileSize: %d\n", state->bytes)); TRACE(("TIFFTileSize: %d\n", state->bytes));
uint32 x, y, tile_y;
uint32 tileWidth, tileLength;
TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tileWidth); TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tileWidth);
TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tileLength); TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tileLength);