avutil/mathematics: Fix division by 0
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 9 Dec 2015 16:39:38 +0000 (17:39 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 14 Dec 2015 15:51:01 +0000 (16:51 +0100)
Fixes: CID1341571

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bc8b1e694cc395fdf5e2917377ef11263c937d85)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavutil/mathematics.c

index 4d8467b..78a87d8 100644 (file)
@@ -90,7 +90,7 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
         else {
             int64_t ad = a / c;
             int64_t a2 = (a % c * b + r) / c;
-            if (ad >= INT32_MAX && ad > (INT64_MAX - a2) / b)
+            if (ad >= INT32_MAX && b && ad > (INT64_MAX - a2) / b)
                 return INT64_MIN;
             return ad * b + a2;
         }