avcodec/jpeg2000dec: Use ff_set_dimensions()

Fixes: OOM
Fixes: 1890/clusterfuzz-testcase-minimized-6329019509243904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f3da6fbff8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2017-05-29 13:45:29 +02:00
parent d1eea5ac86
commit 78bd801c74

View File

@ -231,6 +231,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
uint32_t log2_chroma_wh = 0;
const enum AVPixelFormat *possible_fmts = NULL;
int possible_fmts_nb = 0;
int ret;
if (bytestream2_get_bytes_left(&s->g) < 36)
return AVERROR_INVALIDDATA;
@ -326,10 +327,13 @@ static int get_siz(Jpeg2000DecoderContext *s)
}
/* compute image size with reduction factor */
s->avctx->width = ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,
s->reduction_factor);
s->avctx->height = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
s->reduction_factor);
ret = ff_set_dimensions(s->avctx,
ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,
s->reduction_factor),
ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
s->reduction_factor));
if (ret < 0)
return ret;
if (s->avctx->profile == FF_PROFILE_JPEG2000_DCINEMA_2K ||
s->avctx->profile == FF_PROFILE_JPEG2000_DCINEMA_4K) {