Commit 80344959 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/jpeg2000dec: Free lengthinc earlier

Reduces memory needed
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 4b2a186e
...@@ -1046,6 +1046,8 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, ...@@ -1046,6 +1046,8 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
nb_code_blocks = prec->nb_codeblocks_height * prec->nb_codeblocks_width; nb_code_blocks = prec->nb_codeblocks_height * prec->nb_codeblocks_width;
for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) { for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno; Jpeg2000Cblk *cblk = prec->cblk + cblkno;
if (!cblk->nb_terminationsinc && !cblk->lengthinc)
continue;
for (cwsno = 0; cwsno < cblk->nb_lengthinc; cwsno ++) { for (cwsno = 0; cwsno < cblk->nb_lengthinc; cwsno ++) {
if (cblk->data_allocated < cblk->length + cblk->lengthinc[cwsno] + 4) { if (cblk->data_allocated < cblk->length + cblk->lengthinc[cwsno] + 4) {
size_t new_size = FFMAX(2*cblk->data_allocated, cblk->length + cblk->lengthinc[cwsno] + 4); size_t new_size = FFMAX(2*cblk->data_allocated, cblk->length + cblk->lengthinc[cwsno] + 4);
...@@ -1075,6 +1077,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, ...@@ -1075,6 +1077,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
cblk->data_start[cblk->nb_terminations] = cblk->length; cblk->data_start[cblk->nb_terminations] = cblk->length;
} }
} }
av_freep(&cblk->lengthinc);
} }
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment