[FFmpeg-devel] [PATCH] avcodec/wma: handle run_level_decode error

Stéphane Cerveau scerveau at collabora.com
Wed Aug 11 17:54:12 EEST 2021


Consider data as invalid if ff_wma_run_level_decode
gets out with an error.

It avoids an unpleasant sound distorsion.

See http://trac.ffmpeg.org/ticket/9358
---
 libavcodec/wmadec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index d627bbe50e..74ea8cea77 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -606,10 +606,11 @@ static int wma_decode_block(WMACodecContext *s)
              * there is potentially less energy there */
             tindex = (ch == 1 && s->ms_stereo);
             memset(ptr, 0, s->block_len * sizeof(WMACoef));
-            ff_wma_run_level_decode(s->avctx, &s->gb, &s->coef_vlc[tindex],
+            if (ff_wma_run_level_decode(s->avctx, &s->gb, &s->coef_vlc[tindex],
                                     s->level_table[tindex], s->run_table[tindex],
                                     0, ptr, 0, nb_coefs[ch],
-                                    s->block_len, s->frame_len_bits, coef_nb_bits);
+                                    s->block_len, s->frame_len_bits, coef_nb_bits))
+              return AVERROR_INVALIDDATA;
         }
         if (s->version == 1 && s->avctx->channels >= 2)
             align_get_bits(&s->gb);
-- 
2.25.1



More information about the ffmpeg-devel mailing list