Update j2k.c

This commit is contained in:
Jarrel Seah 2019-11-18 07:16:29 +11:00 committed by GitHub
parent 64fa86061c
commit 6c1225989a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 3 deletions

View File

@ -4747,8 +4747,15 @@ static OPJ_BOOL opj_j2k_read_sod(opj_j2k_t *p_j2k,
/* LH: oddly enough, in this path, l_tile_len!=0. /* LH: oddly enough, in this path, l_tile_len!=0.
* TODO: If this was consistent, we could simplify the code to only use realloc(), as realloc(0,...) default to malloc(0,...). * TODO: If this was consistent, we could simplify the code to only use realloc(), as realloc(0,...) default to malloc(0,...).
*/ */
*l_current_data = (OPJ_BYTE*) opj_malloc( if (!truncate)
p_j2k->m_specific_param.m_decoder.m_sot_length + OPJ_COMMON_CBLK_DATA_EXTRA); {
*l_current_data = (OPJ_BYTE*) opj_malloc(
p_j2k->m_specific_param.m_decoder.m_sot_length + OPJ_COMMON_CBLK_DATA_EXTRA);
}
else
{
*l_current_data = (OPJ_BYTE*) opj_malloc(opj_stream_get_number_byte_left(p_stream) + OPJ_COMMON_CBLK_DATA_EXTRA);
}
} else { } else {
OPJ_BYTE *l_new_current_data; OPJ_BYTE *l_new_current_data;
if (*l_tile_len > UINT_MAX - OPJ_COMMON_CBLK_DATA_EXTRA - if (*l_tile_len > UINT_MAX - OPJ_COMMON_CBLK_DATA_EXTRA -
@ -4758,10 +4765,18 @@ static OPJ_BOOL opj_j2k_read_sod(opj_j2k_t *p_j2k,
"p_j2k->m_specific_param.m_decoder.m_sot_length"); "p_j2k->m_specific_param.m_decoder.m_sot_length");
return OPJ_FALSE; return OPJ_FALSE;
} }
if (!truncate)
{
l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_current_data, l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_current_data,
*l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length + *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length +
OPJ_COMMON_CBLK_DATA_EXTRA); OPJ_COMMON_CBLK_DATA_EXTRA);
}
else
{
l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_current_data,
*l_tile_len + opj_stream_get_number_byte_left(p_stream) +
OPJ_COMMON_CBLK_DATA_EXTRA);
}
if (! l_new_current_data) { if (! l_new_current_data) {
opj_free(*l_current_data); opj_free(*l_current_data);
/*nothing more is done as l_current_data will be set to null, and just /*nothing more is done as l_current_data will be set to null, and just