X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmpc7.c;h=272e1b28ba162f66ea96ad032b3dfe7f5af25e18;hb=e1b2f6ec119dc43a66ff731b98c768778497ff95;hp=ba8828eb52cca358edecf26def4957a6445956af;hpb=3e1a7ae44a97f20bbc9da0eba000663ef74e1890;p=ffmpeg diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index ba8828eb52c..272e1b28ba1 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -197,12 +197,19 @@ static int mpc7_decode_frame(AVCodecContext * avctx, int i, ch; int mb = -1; Band *bands = c->bands; - int off; + int off, out_size; int bits_used, bits_avail; memset(bands, 0, sizeof(bands)); if(buf_size <= 4){ av_log(avctx, AV_LOG_ERROR, "Too small buffer passed (%i bytes)\n", buf_size); + return AVERROR(EINVAL); + } + + out_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4; + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); } bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE); @@ -277,7 +284,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, *data_size = 0; return buf_size; } - *data_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4; + *data_size = out_size; return buf_size; }