avcodec/mpc8: check for overread first

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2018-03-29 21:36:56 +02:00
parent af043b839c
commit 91bb871376

View File

@ -419,11 +419,11 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
c->last_bits_used = get_bits_count(gb);
if(c->cur_frame >= c->frames)
c->cur_frame = 0;
if(c->cur_frame == 0 && get_bits_left(gb) < 8) {// we have only padding left
c->last_bits_used = buf_size << 3;
} else if (get_bits_left(gb) < 0) {
if (get_bits_left(gb) < 0) {
av_log(avctx, AV_LOG_ERROR, "Overread %d\n", -get_bits_left(gb));
c->last_bits_used = buf_size << 3;
} else if (c->cur_frame == 0 && get_bits_left(gb) < 8) {// we have only padding left
c->last_bits_used = buf_size << 3;
}
*got_frame_ptr = 1;