diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index d9d650e15..e96e747f5 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -7945,6 +7945,17 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k, if (tileno + 1 == parameters->POC[i].tile) { opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile]; + if (parameters->POC[numpocs_tile].compno0 >= image->numcomps) { + opj_event_msg(p_manager, EVT_ERROR, + "Invalid compno0 for POC %d\n", i); + return OPJ_FALSE; + } + if (parameters->POC[numpocs_tile].compno1 >= image->numcomps + 1) { + opj_event_msg(p_manager, EVT_ERROR, + "Invalid compno1 for POC %d\n", i); + return OPJ_FALSE; + } + tcp_poc->resno0 = parameters->POC[numpocs_tile].resno0; tcp_poc->compno0 = parameters->POC[numpocs_tile].compno0; tcp_poc->layno1 = parameters->POC[numpocs_tile].layno1;