File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1229,9 +1229,17 @@ static OPJ_BOOL opj_t2_read_packet_header(opj_t2_t* p_t2,
12291229 while (!opj_tgt_decode (l_bio , l_prc -> imsbtree , cblkno , (OPJ_INT32 )i )) {
12301230 ++ i ;
12311231 }
1232-
12331232 l_cblk -> Mb = (OPJ_UINT32 )l_band -> numbps ;
1234- l_cblk -> numbps = (OPJ_UINT32 )l_band -> numbps + 1 - i ;
1233+ if ((OPJ_UINT32 )l_band -> numbps + 1 < i ) {
1234+ /* Not totally sure what we should do in that situation,
1235+ * but that avoids the integer overflow of
1236+ * https://github.com/uclouvain/openjpeg/pull/1488
1237+ * while keeping the regression test suite happy.
1238+ */
1239+ l_cblk -> numbps = (OPJ_UINT32 )(l_band -> numbps + 1 - (int )i );
1240+ } else {
1241+ l_cblk -> numbps = (OPJ_UINT32 )l_band -> numbps + 1 - i ;
1242+ }
12351243 l_cblk -> numlenbits = 3 ;
12361244 }
12371245
You can’t perform that action at this time.
0 commit comments