Fix an integer overflow issue (#809)

Prevent an integer overflow issue in function opj_pi_create_decode of
pi.c.
This commit is contained in:
trylab 2016-09-06 13:55:49 +08:00 committed by Matthieu Darbois
parent ea320dab8b
commit c16bc057ba
1 changed files with 7 additions and 1 deletions

View File

@ -1237,7 +1237,13 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
l_current_pi = l_pi; l_current_pi = l_pi;
/* memory allocation for include */ /* memory allocation for include */
/* prevent an integer overflow issue */
l_current_pi->include = 00;
if (l_step_l <= (SIZE_MAX / (l_tcp->numlayers + 1U)))
{
l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16)); l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16));
}
if if
(!l_current_pi->include) (!l_current_pi->include)
{ {