[FFmpeg-cvslog] wmapro: Validate the number of audio channels before using it

Laurent Aimar git at videolan.org
Mon Mar 19 05:30:27 CET 2012


ffmpeg | branch: release/0.8 | Laurent Aimar <fenrir at videolan.org> | Mon Sep 26 22:18:29 2011 +0000| [04b71cdedd7421d09e12600d7999fab87d35a908] | committer: Reinhard Tartler

wmapro: Validate the number of audio channels before using it

Signed-off-by: Janne Grunau <janne-libav at jannau.net>
(cherry picked from commit 2c1ba7994190fa2f1ad430594551070a49353bd1)

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=04b71cdedd7421d09e12600d7999fab87d35a908
---

 libavcodec/wmaprodec.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 4ba8c45..8fa1573 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -309,10 +309,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
     s->samples_per_frame = 1 << ff_wma_get_frame_len_bits(avctx->sample_rate,
                                                           3, s->decode_flags);
 
-    /** init previous block len */
-    for (i = 0; i < avctx->channels; i++)
-        s->channel[i].prev_block_len = s->samples_per_frame;
-
     /** subframe info */
     log2_max_num_subframes       = ((s->decode_flags & 0x38) >> 3);
     s->max_num_subframes         = 1 << log2_max_num_subframes;
@@ -332,6 +328,18 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     s->num_channels = avctx->channels;
 
+    if (s->num_channels < 0) {
+        av_log(avctx, AV_LOG_ERROR, "invalid number of channels %d\n", s->num_channels);
+        return AVERROR_INVALIDDATA;
+    } else if (s->num_channels > WMAPRO_MAX_CHANNELS) {
+        av_log_ask_for_sample(avctx, "unsupported number of channels\n");
+        return AVERROR_PATCHWELCOME;
+    }
+
+    /** init previous block len */
+    for (i = 0; i < s->num_channels; i++)
+        s->channel[i].prev_block_len = s->samples_per_frame;
+
     /** extract lfe channel position */
     s->lfe_channel = -1;
 
@@ -343,14 +351,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
         }
     }
 
-    if (s->num_channels < 0) {
-        av_log(avctx, AV_LOG_ERROR, "invalid number of channels %d\n", s->num_channels);
-        return AVERROR_INVALIDDATA;
-    } else if (s->num_channels > WMAPRO_MAX_CHANNELS) {
-        av_log_ask_for_sample(avctx, "unsupported number of channels\n");
-        return AVERROR_PATCHWELCOME;
-    }
-
     INIT_VLC_STATIC(&sf_vlc, SCALEVLCBITS, HUFF_SCALE_SIZE,
                     scale_huffbits, 1, 1,
                     scale_huffcodes, 2, 2, 616);



More information about the ffmpeg-cvslog mailing list