From 1cea02a2f6455ec7dd247ec099509b11dc4520bd Mon Sep 17 00:00:00 2001 From: Iceyer Date: Mon, 22 Jan 2018 13:38:50 +0800 Subject: [PATCH] common: Fix division by zero when calculate progress Closes: #1331 Approved by: alexlarsson --- common/flatpak-utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index 56b5e672..92fab574 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -6573,7 +6573,11 @@ progress_cb (OstreeAsyncProgress *progress, gpointer user_data) } /* The download progress goes up to 97% */ - new_progress = 5 + ((total_transferred / (gdouble) total) * 92); + if (total > 0) { + new_progress = 5 + ((total_transferred / (gdouble) total) * 92); + } else { + new_progress = 97; + } /* And the writing of the objects adds 3% to the progress */ new_progress += get_write_progress (outstanding_writes);