1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

jpeg2000dec: Propagate error code from get_cox() correctly

Without this the context state could become inconsistent

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-06-05 17:23:34 +02:00
parent 6e9bfc19bd
commit 66c4d54413

View File

@ -310,7 +310,7 @@ static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
uint8_t *properties) uint8_t *properties)
{ {
Jpeg2000CodingStyle tmp; Jpeg2000CodingStyle tmp;
int compno; int compno, ret;
if (bytestream2_get_bytes_left(&s->g) < 5) if (bytestream2_get_bytes_left(&s->g) < 5)
return AVERROR(EINVAL); return AVERROR(EINVAL);
@ -323,7 +323,9 @@ static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
tmp.nlayers = bytestream2_get_be16u(&s->g); tmp.nlayers = bytestream2_get_be16u(&s->g);
tmp.mct = bytestream2_get_byteu(&s->g); // multiple component transformation tmp.mct = bytestream2_get_byteu(&s->g); // multiple component transformation
get_cox(s, &tmp); if ((ret = get_cox(s, &tmp)) < 0)
return ret;
for (compno = 0; compno < s->ncomponents; compno++) for (compno = 0; compno < s->ncomponents; compno++)
if (!(properties[compno] & HAD_COC)) if (!(properties[compno] & HAD_COC))
memcpy(c + compno, &tmp, sizeof(tmp)); memcpy(c + compno, &tmp, sizeof(tmp));
@ -335,7 +337,7 @@ static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c, static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
uint8_t *properties) uint8_t *properties)
{ {
int compno; int compno, ret;
if (bytestream2_get_bytes_left(&s->g) < 2) if (bytestream2_get_bytes_left(&s->g) < 2)
return AVERROR(EINVAL); return AVERROR(EINVAL);
@ -344,7 +346,9 @@ static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
c += compno; c += compno;
c->csty = bytestream2_get_byteu(&s->g); c->csty = bytestream2_get_byteu(&s->g);
get_cox(s, c);
if ((ret = get_cox(s, c)) < 0)
return ret;
properties[compno] |= HAD_COC; properties[compno] |= HAD_COC;
return 0; return 0;