Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix assertion in debug mode / heap-based buffer overflow in opj_write…
…_bytes_LE for Cinema profiles with numresolutions = 1 (#985)
  • Loading branch information
rouault committed Aug 15, 2017
1 parent 52d5690 commit 4241ae6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib/openjp2/j2k.c
Expand Up @@ -6573,10 +6573,16 @@ static void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters,

/* Precincts */
parameters->csty |= 0x01;
parameters->res_spec = parameters->numresolution - 1;
for (i = 0; i < parameters->res_spec; i++) {
parameters->prcw_init[i] = 256;
parameters->prch_init[i] = 256;
if (parameters->numresolution == 1) {
parameters->res_spec = 1;
parameters->prcw_init[0] = 128;
parameters->prch_init[0] = 128;
} else {
parameters->res_spec = parameters->numresolution - 1;
for (i = 0; i < parameters->res_spec; i++) {
parameters->prcw_init[i] = 256;
parameters->prch_init[i] = 256;
}
}

/* The progression order shall be CPRL */
Expand Down

0 comments on commit 4241ae6

Please sign in to comment.