]> git.ipfire.org Git - pakfire.git/commitdiff
progressbar: Avoid dividing by zero when max isn't set
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 10 Apr 2021 17:46:46 +0000 (17:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 10 Apr 2021 17:46:46 +0000 (17:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/progressbar.c

index 318f02942f52b902172febc9c27d1abf55fc0b44..d856a8177b564e2d7a9813790c64b63f62eefb10 100644 (file)
@@ -455,7 +455,10 @@ static const char* pakfire_progressbar_bar(struct pakfire_progressbar* p,
        if (width >= sizeof(widget->buffer) || width < 2)
                return NULL;
 
-       unsigned int fill = p->value * (width - 2) / p->value_max;
+       unsigned int fill = 0;
+
+       if (p->value_max)
+               fill = p->value * (width - 2) / p->value_max;
 
        // Write brackets
        widget->buffer[0] = '[';