pcmdec: check that channels is valid.
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 9 Nov 2012 19:47:54 +0000 (20:47 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 9 Nov 2012 20:06:01 +0000 (21:06 +0100)
Prevents a division by 0

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/pcm.c

index 85a5fe6..47a5509 100644 (file)
@@ -288,6 +288,11 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
         return AVERROR(EINVAL);
     }
 
+    if (avctx->channels == 0) {
+        av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
+        return AVERROR(EINVAL);
+    }
+
     n = avctx->channels * sample_size;
 
     if (n && buf_size % n) {