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 Mathieu Malaterre
parent 3547402709
commit 5196bda0b9
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 */
l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16)); /* 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));
}
if if
(!l_current_pi->include) (!l_current_pi->include)
{ {