imc: Catch a division by zero
authorLuca Barbato <lu_zero@gentoo.org>
Tue, 9 Jul 2013 07:19:30 +0000 (09:19 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 9 Jul 2013 14:20:50 +0000 (16:20 +0200)
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Reviewed-by: Kostya Shishkov
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/imc.c

index eb7c255..deec0a1 100644 (file)
@@ -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;