[1.5] division by zero in j2k_read_siz

Fixes issue 169
This commit is contained in:
Mathieu Malaterre 2012-10-02 07:09:57 +00:00
parent c02f145cd1
commit e55d5e29e0
1 changed files with 12 additions and 0 deletions

View File

@ -468,6 +468,12 @@ static void j2k_read_siz(opj_j2k_t *j2k) {
} }
#endif /* USE_JPWL */ #endif /* USE_JPWL */
/* prevent division by zero */
if (!(cp->tdx * cp->tdy)) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: invalid tile size (tdx: %d, tdy: %d)\n", cp->tdx, cp->tdy);
return;
}
image->comps = (opj_image_comp_t*) opj_calloc(image->numcomps, sizeof(opj_image_comp_t)); image->comps = (opj_image_comp_t*) opj_calloc(image->numcomps, sizeof(opj_image_comp_t));
for (i = 0; i < image->numcomps; i++) { for (i = 0; i < image->numcomps; i++) {
int tmp, w, h; int tmp, w, h;
@ -506,6 +512,12 @@ static void j2k_read_siz(opj_j2k_t *j2k) {
} }
#endif /* USE_JPWL */ #endif /* USE_JPWL */
/* prevent division by zero */
if (!(image->comps[i].dx * image->comps[i].dy)) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: invalid component size (dx: %d, dy: %d)\n", image->comps[i].dx, image->comps[i].dy);
return;
}
/* TODO: unused ? */ /* TODO: unused ? */
w = int_ceildiv(image->x1 - image->x0, image->comps[i].dx); w = int_ceildiv(image->x1 - image->x0, image->comps[i].dx);
h = int_ceildiv(image->y1 - image->y0, image->comps[i].dy); h = int_ceildiv(image->y1 - image->y0, image->comps[i].dy);