From 25e875c330e76c2c6be30231e9730fa3a2f30115 Mon Sep 17 00:00:00 2001 From: Thilo Borgmann Date: Sat, 4 Jun 2022 13:45:30 +0200 Subject: [PATCH 1/2] lavfi/blockdetect: Fix possible div by 0 Found-by Covererity, CID 1504568, 1504569 --- libavfilter/vf_blockdetect.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavfilter/vf_blockdetect.c b/libavfilter/vf_blockdetect.c index 8503b8d..85fca68 100644 --- a/libavfilter/vf_blockdetect.c +++ b/libavfilter/vf_blockdetect.c @@ -132,8 +132,10 @@ static float calculate_blockiness(BLKContext *s, int w, int h, nonblock_count++; } } + if (block_count && nonblock_count) { temp = (block / block_count) / (nonblock / nonblock_count); ret = FFMAX(ret, temp); + } } // vertical blockiness (fixed height) @@ -175,8 +177,10 @@ static float calculate_blockiness(BLKContext *s, int w, int h, nonblock_count++; } } + if (block_count && nonblock_count) { temp = (block / block_count) / (nonblock / nonblock_count); ret = FFMAX(ret, temp); + } } // return highest value of horz||vert -- 1.8.3.2