[FFmpeg-cvslog] pcmdec: check that channels is valid.

Michael Niedermayer git at videolan.org
Fri Nov 9 21:07:01 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Nov  9 20:47:54 2012 +0100| [b8551f8ea71b7d6ae39de121213860262d911001] | committer: Michael Niedermayer

pcmdec: check that channels is valid.

Prevents a division by 0

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

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

 libavcodec/pcm.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 85a5fe6..47a5509 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -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) {



More information about the ffmpeg-cvslog mailing list