Commit 0aada305 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/jpeg2000dec: More completely check cdef

Fixes out of array read
Fixes: j2k-poc.bin
Found-by: 's avatarLucas Leong <wmliang.tw@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 75a7565b
......@@ -1766,11 +1766,15 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
if (tile->codsty[0].mct)
mct_decode(s, tile);
if (s->cdef[0] < 0) {
for (x = 0; x < s->ncomponents; x++)
s->cdef[x] = x + 1;
if ((s->ncomponents & 1) == 0)
s->cdef[s->ncomponents-1] = 0;
for (x = 0; x < s->ncomponents; x++) {
if (s->cdef[x] < 0) {
for (x = 0; x < s->ncomponents; x++) {
s->cdef[x] = x + 1;
}
if ((s->ncomponents & 1) == 0)
s->cdef[s->ncomponents-1] = 0;
break;
}
}
if (s->precision <= 8) {
......
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