Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Thilo Borgmann" <thilo.borgmann@mail.de>
To: "FFmpeg development discussions and patches" <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavfi/blockdetect: Fix possible div by 0
Date: Sat, 04 Jun 2022 13:57:25 +0200
Message-ID: <DA504A9C-4445-4C9A-A08C-C8480087F414@mail.de> (raw)
In-Reply-To: <BC1AD5ED-BC2A-4582-BB5A-A2421D6CE269@mail.de>

[-- Attachment #1: Type: text/plain, Size: 32 bytes --]

Now with actual patch…

-Thilo

[-- Attachment #2: 0001-lavfi-blockdetect-Fix-possible-div-by-0.patch --]
[-- Type: text/plain, Size: 1273 bytes --]

From 25e875c330e76c2c6be30231e9730fa3a2f30115 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann <thilo.borgmann@mail.de>
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


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-06-04 11:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-04 11:54 Thilo Borgmann
2022-06-04 11:56 ` Andreas Rheinhardt
2022-06-04 11:59   ` Thilo Borgmann
2022-06-04 11:57 ` Thilo Borgmann [this message]
2022-06-04 11:58   ` Thilo Borgmann
2022-06-06  7:10   ` Thilo Borgmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DA504A9C-4445-4C9A-A08C-C8480087F414@mail.de \
    --to=thilo.borgmann@mail.de \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git