diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-09-27 20:39:44 +0300 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-10-04 19:01:01 +0300 |
commit | bf8e40ae0d5975d3c18ef326ae62fe9052e746f6 (patch) | |
tree | a0498e2cff61ffbfd69bf217a9e5b3f24ba8a453 /libavcodec/wmalosslessdec.c | |
parent | 44bdb4efd0753a0c76571a5cbe251c0cc6b0070c (diff) |
avcodec/wmalosslessdec: Simplify flushing, avoid NULL + 0
Return immediately if not enough leftover bits are available
when flushing. This is simpler and also avoids an
init_get_bits(gb, NULL, 0) (which currently leads to NULL + 0,
which is UB; this affects the lossless-wma(|-1|-2|-rawtile)
FATE tests).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/wmalosslessdec.c')
-rw-r--r-- | libavcodec/wmalosslessdec.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 5112b763fa..d545d848e2 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -1192,16 +1192,15 @@ static int decode_packet(AVCodecContext *avctx, AVFrame *rframe, s->frame->nb_samples = 0; - if (!buf_size && s->num_saved_bits > get_bits_count(&s->gb)) { + if (!buf_size) { s->packet_done = 0; + if (s->num_saved_bits <= get_bits_count(&s->gb)) + return 0; if (!decode_frame(s)) s->num_saved_bits = 0; } else if (s->packet_done || s->packet_loss) { s->packet_done = 0; - if (!buf_size) - return 0; - s->next_packet_start = buf_size - FFMIN(avctx->block_align, buf_size); buf_size = FFMIN(avctx->block_align, buf_size); s->buf_bit_size = buf_size << 3; @@ -1299,7 +1298,7 @@ static int decode_packet(AVCodecContext *avctx, AVFrame *rframe, s->packet_offset = get_bits_count(gb) & 7; - return (s->packet_loss) ? AVERROR_INVALIDDATA : buf_size ? get_bits_count(gb) >> 3 : 0; + return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; } static void flush(AVCodecContext *avctx) |