aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2012-02-17 12:10:33 -0800
committerReinhard Tartler <siretart@tauware.de>2012-04-01 18:33:26 +0200
commitd031302e0ec6bfddb905f4827782f9e6e338cf9d (patch)
treeda3e20386e89afe2f39418d0956acfda2b6998ae
parent0fe53216340e2bab1bb07df6fcdc14f742f3e69c (diff)
downloadffmpeg-d031302e0ec6bfddb905f4827782f9e6e338cf9d.tar.gz
cook: prevent div-by-zero if channels is zero.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit 941fc1ea1ed7f7d99a8b9e2607b41f2f2820394a) Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Reinhard Tartler <siretart@tauware.de>
-rw-r--r--libavcodec/cook.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index a8fa01e5d2..429b4d0155 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -1066,6 +1066,10 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
q->sample_rate = avctx->sample_rate;
q->nb_channels = avctx->channels;
q->bit_rate = avctx->bit_rate;
+ if (!q->nb_channels) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
+ return AVERROR_INVALIDDATA;
+ }
/* Initialize RNG. */
av_lfg_init(&q->random_state, 0);