opj_j2k_setup_encoder(): add validation of tile width and height to avoid potential division by zero

This commit is contained in:
Even Rouault 2020-05-19 22:26:22 +02:00
parent c6a413a423
commit 4ab2ed0907
No known key found for this signature in database
GPG Key ID: 33EBBFC47B3DD87D
1 changed files with 8 additions and 0 deletions

View File

@ -7823,6 +7823,14 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
*/
if (parameters->tile_size_on) {
if (cp->tdx == 0) {
opj_event_msg(p_manager, EVT_ERROR, "Invalid tile width\n");
return OPJ_FALSE;
}
if (cp->tdy == 0) {
opj_event_msg(p_manager, EVT_ERROR, "Invalid tile height\n");
return OPJ_FALSE;
}
cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->x1 - cp->tx0),
(OPJ_INT32)cp->tdx);
cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp->ty0),