From 6d2a92c4678616fe342be0b606343ae3ade83641 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 9 Jul 2013 09:18:16 +0200 Subject: [PATCH] imc: Catch a division by zero Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit bbf6a4aa20bfe3d7869b2218e66063602dfb8aa7) Signed-off-by: Luca Barbato --- libavcodec/imc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 5cff70fcb4..316dd77462 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -450,6 +450,10 @@ static int bit_allocation(IMCContext *q, IMCChannel *chctx, iacc += chctx->bandWidthT[i]; summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i]; } + + if (!iacc) + return AVERROR_INVALIDDATA; + chctx->bandWidthT[BANDS - 1] = 0; summa = (summa * 0.5 - freebits) / iacc;