diff mbox series

[FFmpeg-devel,05/20] avcodec/wmadec: Check operations that can fail

Message ID HE1PR0301MB21549E8CE1101F1D1CDD6F2F8F579@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit bd1cbb5427c156f40f1a94c57dac0cf667f34b7b
Headers show
Series [FFmpeg-devel,01/20] avcodec/wma: Remove nonsense volatile
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 7, 2021, 6:46 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/wmadec.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 6eec85e59a..47abcecc9c 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -106,20 +106,31 @@  static av_cold int wma_decode_init(AVCodecContext *avctx)
         return ret;
 
     /* init MDCT */
-    for (i = 0; i < s->nb_block_sizes; i++)
-        ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1, 1.0 / 32768.0);
+    for (i = 0; i < s->nb_block_sizes; i++) {
+        ret = ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1,
+                           1, 1.0 / 32768.0);
+        if (ret < 0)
+            return ret;
+    }
 
     if (s->use_noise_coding) {
-        ff_init_vlc_from_lengths(&s->hgain_vlc, HGAINVLCBITS, FF_ARRAY_ELEMS(ff_wma_hgain_hufftab),
-                                 &ff_wma_hgain_hufftab[0][1], 2,
-                                 &ff_wma_hgain_hufftab[0][0], 2, 1, -18, 0, avctx);
+        ret = ff_init_vlc_from_lengths(&s->hgain_vlc, HGAINVLCBITS,
+                                       FF_ARRAY_ELEMS(ff_wma_hgain_hufftab),
+                                       &ff_wma_hgain_hufftab[0][1], 2,
+                                       &ff_wma_hgain_hufftab[0][0], 2, 1,
+                                       -18, 0, avctx);
+        if (ret < 0)
+            return ret;
     }
 
-    if (s->use_exp_vlc)
-        init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(ff_aac_scalefactor_bits), // FIXME move out of context
-                 ff_aac_scalefactor_bits, 1, 1,
-                 ff_aac_scalefactor_code, 4, 4, 0);
-    else
+    if (s->use_exp_vlc) {
+        // FIXME move out of context
+        ret = init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(ff_aac_scalefactor_bits),
+                       ff_aac_scalefactor_bits, 1, 1,
+                       ff_aac_scalefactor_code, 4, 4, 0);
+        if (ret < 0)
+            return ret;
+    } else
         wma_lsp_to_curve_init(s, s->frame_len);
 
     avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;