mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
mpc8: check output buffer size before decoding
This commit is contained in:
parent
8290d1f38b
commit
5674d4b0a3
@ -241,10 +241,16 @@ static int mpc8_decode_frame(AVCodecContext * avctx,
|
|||||||
GetBitContext gb2, *gb = &gb2;
|
GetBitContext gb2, *gb = &gb2;
|
||||||
int i, j, k, ch, cnt, res, t;
|
int i, j, k, ch, cnt, res, t;
|
||||||
Band *bands = c->bands;
|
Band *bands = c->bands;
|
||||||
int off;
|
int off, out_size;
|
||||||
int maxband, keyframe;
|
int maxband, keyframe;
|
||||||
int last[2];
|
int last[2];
|
||||||
|
|
||||||
|
out_size = MPC_FRAME_SIZE * 2 * avctx->channels;
|
||||||
|
if (*data_size < out_size) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
keyframe = c->cur_frame == 0;
|
keyframe = c->cur_frame == 0;
|
||||||
|
|
||||||
if(keyframe){
|
if(keyframe){
|
||||||
@ -400,7 +406,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx,
|
|||||||
c->last_bits_used = get_bits_count(gb);
|
c->last_bits_used = get_bits_count(gb);
|
||||||
if(c->cur_frame >= c->frames)
|
if(c->cur_frame >= c->frames)
|
||||||
c->cur_frame = 0;
|
c->cur_frame = 0;
|
||||||
*data_size = MPC_FRAME_SIZE * 2 * avctx->channels;
|
*data_size = out_size;
|
||||||
|
|
||||||
return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
|
return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user