From 34acecf544b364a958f0ffadd88be52c5bdd63e5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 31 Jan 2017 00:11:10 +0100 Subject: [PATCH] nm-online: fix division-by-zero with zero timeout $ nm-online -t 0 Floating point exception (core dumped) Fixes: c5f17a97ea8e4cee85c93ee9cfa04057f83e13ab https://bugzilla.gnome.org/show_bug.cgi?id=777914 --- clients/nm-online.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/nm-online.c b/clients/nm-online.c index c1df195aaf..92f564929e 100644 --- a/clients/nm-online.c +++ b/clients/nm-online.c @@ -227,7 +227,7 @@ main (int argc, char *argv[]) remaining_ms = t_secs * 1000; data.end_timestamp_ms = data.start_timestamp_ms + remaining_ms; - data.progress_step_duration = (data.end_timestamp_ms - data.start_timestamp_ms + PROGRESS_STEPS/2) / PROGRESS_STEPS; + data.progress_step_duration = NM_MAX (1, (data.end_timestamp_ms - data.start_timestamp_ms + PROGRESS_STEPS/2) / PROGRESS_STEPS); g_timeout_add (data.quiet ? remaining_ms : 0, handle_timeout, &data); nm_client_new_async (NULL, got_client, &data);