imc: Catch a division by zero
authorLuca Barbato <lu_zero@gentoo.org>
Tue, 9 Jul 2013 07:18:16 +0000 (09:18 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Tue, 9 Jul 2013 08:49:29 +0000 (10:49 +0200)
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
libavcodec/imc.c

index 2749099..e3f5e15 100644 (file)
@@ -449,6 +449,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;