battery_remaining: check for division by zero

This commit is contained in:
Aaron Marcher 2018-05-21 00:42:06 +02:00
parent a546d4b585
commit aa8654795d
1 changed files with 4 additions and 0 deletions

View File

@ -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;