Removed buffer_size variable

This commit is contained in:
Andrew Murray 2024-12-28 15:41:19 +11:00
parent 4e82f2bec0
commit 05c981ffd7

View File

@ -640,7 +640,7 @@ j2k_decode_entry(Imaging im, ImagingCodecState state) {
opj_dparameters_t params; opj_dparameters_t params;
OPJ_COLOR_SPACE color_space; OPJ_COLOR_SPACE color_space;
j2k_unpacker_t unpack = NULL; j2k_unpacker_t unpack = NULL;
size_t buffer_size = 0, tile_bytes = 0; size_t tile_bytes = 0;
unsigned n, tile_height, tile_width; unsigned n, tile_height, tile_width;
int subsampling; int subsampling;
int total_component_width = 0; int total_component_width = 0;
@ -870,7 +870,7 @@ j2k_decode_entry(Imaging im, ImagingCodecState state) {
tile_info.data_size = tile_bytes; tile_info.data_size = tile_bytes;
} }
if (buffer_size < tile_info.data_size) { if (tile_info.data_size > 0) {
/* malloc check ok, overflow and tile size sanity check above */ /* malloc check ok, overflow and tile size sanity check above */
UINT8 *new = realloc(state->buffer, tile_info.data_size); UINT8 *new = realloc(state->buffer, tile_info.data_size);
if (!new) { if (!new) {
@ -883,7 +883,6 @@ j2k_decode_entry(Imaging im, ImagingCodecState state) {
to valgrind errors. */ to valgrind errors. */
memset(new, 0, tile_info.data_size); memset(new, 0, tile_info.data_size);
state->buffer = new; state->buffer = new;
buffer_size = tile_info.data_size;
} }
if (!opj_decode_tile_data( if (!opj_decode_tile_data(