Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Cast to size_t before multiplication
Need to cast to size_t before multiplication otherwise overflow check is useless.
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1241,7 +1241,7 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image, | |
| 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((size_t)(l_tcp->numlayers + 1U) * l_step_l, sizeof(OPJ_INT16)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mayeut
Author
Collaborator
|
||
| } | ||
|
|
||
| if | ||
|
|
||
I'd cast
l_tcp->numlayersinstead of the result of the addition. Otherwise the addition could overflow (resulting in 0). I admit that the chances that this will happen are very low. Or do we know thatl_tcp->numlayerscan never reachUINT32_MAX?