diff options
author | Nicolas Bertrand <nicoinattendu@gmail.com> | 2013-04-29 12:25:09 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-05-06 21:14:19 +0200 |
commit | a06f0cef5bd4bef57338e3396ea903a3d887a0e4 (patch) | |
tree | e1d696ae6e837b06fc811ad83edf2b9fcbacdfd0 /libavcodec/jpeg2000dec.c | |
parent | 108e2ae8299a221e78c549a69c09a5eb1cebbd6c (diff) | |
download | ffmpeg-a06f0cef5bd4bef57338e3396ea903a3d887a0e4.tar.gz |
jpeg2000: fix for uninitialized data errors in valgrind/memcheck
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/jpeg2000dec.c')
-rw-r--r-- | libavcodec/jpeg2000dec.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index f9309be1ef..ac801edba8 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -635,7 +635,14 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Cblk *cblk = prec->cblk + cblkno; if (s->buf_end - s->buf < cblk->lengthinc) return AVERROR(EINVAL); - bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc); + /* A code-block data can be empty. In that case initialize data + * with 0xffff. */ + if (cblk->lengthinc > 0) + bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc); + else { + cblk->data[0] = 0xff; + cblk->data[1] = 0xff; + } cblk->length += cblk->lengthinc; cblk->lengthinc = 0; } @@ -853,12 +860,15 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, { int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y; - for (y = 0; y < height + 2; y++) - memset(t1->flags[y], 0, (width + 2) * sizeof(width)); - for (y = 0; y < height; y++) memset(t1->data[y], 0, width * sizeof(width)); + /* If code-block contains no compressed data: nothing to do. */ + if (cblk->length == 0) + return 0; + for (y = 0; y < height + 2; y++) + memset(t1->flags[y], 0, (width + 2) * sizeof(width)); + ff_mqc_initdec(&t1->mqc, cblk->data); cblk->data[cblk->length] = 0xff; cblk->data[cblk->length + 1] = 0xff; |