From b8551f8ea71b7d6ae39de121213860262d911001 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 9 Nov 2012 20:47:54 +0100 Subject: [PATCH] pcmdec: check that channels is valid. Prevents a division by 0 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/pcm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index 85a5fe6ed4..47a55091b3 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) {