summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Marcher <me@drkhsh.at>2018-05-21 00:42:06 +0200
committerAaron Marcher <me@drkhsh.at>2018-05-21 00:42:06 +0200
commitaa8654795da19a8d517faf1b84cd4dc4ac75f6e7 (patch)
treeedd948e4e767415096f190a36aa898c69e1de80b
parenta546d4b585234f66b82e048c2d7cb228b9e7fea4 (diff)
battery_remaining: check for division by zero
-rw-r--r--components/battery.c4
1 files changed, 4 insertions, 0 deletions
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;