X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fjpeg2000.c;h=8e90980976e52772bd215e518a3baf58c615cd3f;hb=c71e1e60305669c225c696dd99f6db5dc550a56a;hp=5f3965047fba8937ce5616498f5a074c3e0bfe39;hpb=374f818bfbc5f7ad3a88f6a17770abb14abec4d1;p=ffmpeg diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 5f3965047fb..8e90980976e 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -359,7 +359,6 @@ static int init_prec(Jpeg2000Band *band, cblk->lblock = 3; cblk->length = 0; - memset(cblk->lengthinc, 0, sizeof(cblk->lengthinc)); cblk->npasses = 0; } @@ -542,6 +541,9 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, if (!reslevel->band) return AVERROR(ENOMEM); + if (reslevel->num_precincts_x * (uint64_t)reslevel->num_precincts_y * reslevel->nbands > avctx->max_pixels / sizeof(*reslevel->band->prec)) + return AVERROR(ENOMEM); + for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) { ret = init_band(avctx, reslevel, comp, codsty, qntsty, @@ -607,6 +609,8 @@ void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty) Jpeg2000Cblk *cblk = &prec->cblk[cblkno]; av_freep(&cblk->data); av_freep(&cblk->passes); + av_freep(&cblk->lengthinc); + av_freep(&cblk->data_start); } av_freep(&prec->cblk); }