From f302bbcb0359f7c7533524ae0cd5ae2afc92b330 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 24 Sep 2021 18:27:57 +0100 Subject: [PATCH] trivial: Fix a potential division by zero Spotted by Coverity. --- libfwupdplugin/fu-progress.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libfwupdplugin/fu-progress.c b/libfwupdplugin/fu-progress.c index f27b280c1..bc42bdee5 100644 --- a/libfwupdplugin/fu-progress.c +++ b/libfwupdplugin/fu-progress.c @@ -564,6 +564,8 @@ fu_progress_get_step_percentage(FuProgress *self, guint idx) current += step->value; total += step->value; } + if (total == 0) + return 0; return ((gdouble)current * 100.f) / (gdouble)total; }