Browse code

avcodec/wmaprodec: check number of channels for XMA streams

Signed-off-by: Paul B Mahol <onemda@gmail.com>

Paul B Mahol authored on 2017/01/19 23:42:47
Showing 1 changed files
... ...
@@ -1825,8 +1825,13 @@ static av_cold int xma_decode_init(AVCodecContext *avctx)
1825 1825
     XMADecodeCtx *s = avctx->priv_data;
1826 1826
     int i, ret;
1827 1827
 
1828
-    for (i = 0; i < avctx->channels / 2; i++) {
1828
+    if (avctx->channels <= 0 || avctx->channels > 8)
1829
+        return AVERROR_INVALIDDATA;
1830
+
1831
+    for (i = 0; i < (avctx->channels + 1) / 2; i++) {
1829 1832
         ret = decode_init(&s->xma[i], avctx);
1833
+        if (ret < 0)
1834
+            return ret;
1830 1835
         s->frames[i] = av_frame_alloc();
1831 1836
         if (!s->frames[i])
1832 1837
             return AVERROR(ENOMEM);