From aa8654795da19a8d517faf1b84cd4dc4ac75f6e7 Mon Sep 17 00:00:00 2001 From: Aaron Marcher Date: Mon, 21 May 2018 00:42:06 +0200 Subject: battery_remaining: check for division by zero --- components/battery.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'components/battery.c') diff --git a/components/battery.c b/components/battery.c index fa525be..8bfe42a 100644 --- a/components/battery.c +++ b/components/battery.c @@ -107,6 +107,10 @@ return NULL; } + if (current_now == 0) { + return NULL; + } + timeleft = (double)charge_now / (double)current_now; h = timeleft; m = (timeleft - (double)h) * 60; -- cgit v1.2.3