Explorar el Código

battery_remaining: check for division by zero

Aaron Marcher hace 7 años
padre
commit
aa8654795d
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      components/battery.c

+ 4 - 0
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;