Index: openjpeg-1.5.1/libopenjpeg/j2k.c =================================================================== --- openjpeg-1.5.1.orig/libopenjpeg/j2k.c 2013-01-01 01:01:01.000000000 +0000 +++ openjpeg-1.5.1/libopenjpeg/j2k.c 2013-01-01 01:01:01.000000000 +0000 @@ -920,6 +920,13 @@ static void j2k_read_qcx(opj_j2k_t *j2k, }; }; +#else + /* We check whether there are too many subbands */ + if ((numbands < 0) || (numbands >= J2K_MAXBANDS)) { + opj_event_msg(j2k->cinfo, EVT_WARNING , + "bad number of subbands in Sqcx (%d) regarding to J2K_MAXBANDS (%d) \n" + "- limiting number of bands to J2K_MAXBANDS and try to move to the next markers\n", numbands, J2K_MAXBANDS); + } #endif /* USE_JPWL */ for (bandno = 0; bandno < numbands; bandno++) { @@ -932,8 +939,10 @@ static void j2k_read_qcx(opj_j2k_t *j2k, expn = tmp >> 11; mant = tmp & 0x7ff; } - tccp->stepsizes[bandno].expn = expn; - tccp->stepsizes[bandno].mant = mant; + if (bandno < J2K_MAXBANDS) { + tccp->stepsizes[bandno].expn = expn; + tccp->stepsizes[bandno].mant = mant; + } } /* Add Antonin : if scalar_derived -> compute other stepsizes */