jpeg2000: Fix uninitialized data errors pointed out by valgrind/memcheck
Signed-off-by: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
parent
110796739a
commit
28816f9db8
@ -635,7 +635,14 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
|
|||||||
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
|
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
|
||||||
if (s->buf_end - s->buf < cblk->lengthinc)
|
if (s->buf_end - s->buf < cblk->lengthinc)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
/* 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);
|
bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc);
|
||||||
|
} else {
|
||||||
|
cblk->data[0] = 0xFF;
|
||||||
|
cblk->data[1] = 0xFF;
|
||||||
|
}
|
||||||
cblk->length += cblk->lengthinc;
|
cblk->length += cblk->lengthinc;
|
||||||
cblk->lengthinc = 0;
|
cblk->lengthinc = 0;
|
||||||
}
|
}
|
||||||
@ -853,11 +860,13 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
|
|||||||
{
|
{
|
||||||
int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y;
|
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++)
|
for (y = 0; y < height; y++)
|
||||||
memset(t1->data[y], 0, width * sizeof(width));
|
memset(t1->data[y], 0, width * sizeof(width));
|
||||||
|
/* If code-block contains no compressed data: nothing to do. */
|
||||||
|
if (!cblk->length)
|
||||||
|
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);
|
ff_mqc_initdec(&t1->mqc, cblk->data);
|
||||||
cblk->data[cblk->length] = 0xff;
|
cblk->data[cblk->length] = 0xff;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user