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>
Fri, 13 Sep 2013 13:49:23 +0000 (15:49 +0200)
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
(cherry picked from commit bbf6a4aa20bfe3d7869b2218e66063602dfb8aa7)

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Conflicts:
libavcodec/imc.c

libavcodec/imc.c

index ff8e31e..bee38b0 100644 (file)
@@ -365,6 +365,10 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
         iacc += q->bandWidthT[i];
         summa += q->bandWidthT[i] * q->flcoeffs4[i];
     }
+
+    if (!iacc)
+        return AVERROR_INVALIDDATA;
+
     q->bandWidthT[BANDS-1] = 0;
     summa = (summa * 0.5 - freebits) / iacc;