From 5d7f3b2639923cf054cab917a11ec90ae600ec07 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 25 Nov 2022 18:34:21 +0100 Subject: [PATCH] avcodec/apac: stop adding samples if we run out of bits on EOF --- libavcodec/apac.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/apac.c b/libavcodec/apac.c index e9f6a0dd88..784abb622c 100644 --- a/libavcodec/apac.c +++ b/libavcodec/apac.c @@ -196,10 +196,14 @@ static int apac_decode(AVCodecContext *avctx, AVFrame *frame, return AVERROR_INVALIDDATA; } - if (get_bits_left(gb) < c->block_length * c->bit_length && pkt->size) { - c->have_code = 1; - s->cur_ch = ch; - goto end; + if (get_bits_left(gb) < c->block_length * c->bit_length) { + if (pkt->size) { + c->have_code = 1; + s->cur_ch = ch; + goto end; + } else { + break; + } } for (int i = 0; i < c->block_length; i++) {