Fix an integer overflow issue

Making it more secure to call opj_calloc.
This commit is contained in:
trylab 2016-08-23 17:02:21 +08:00
parent 713429b8fa
commit 7f703c696b
1 changed files with 1 additions and 1 deletions

View File

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