avcodec/agm: Check output size before allocation

Fixes: OOM
Fixes: 14198/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5723579234123776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
pull/310/head
Michael Niedermayer 6 years ago
parent f4a1b8d409
commit 19af948e53
  1. 3
      libavcodec/agm.c

@ -1049,6 +1049,9 @@ static int decode_huffman2(AVCodecContext *avctx, int header, int size)
s->output_size = get_bits_long(gb, 32); s->output_size = get_bits_long(gb, 32);
if (s->output_size > avctx->width * avctx->height * 9LL + 10000)
return AVERROR_INVALIDDATA;
av_fast_padded_malloc(&s->output, &s->padded_output_size, s->output_size); av_fast_padded_malloc(&s->output, &s->padded_output_size, s->output_size);
if (!s->output) if (!s->output)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);

Loading…
Cancel
Save