Explorar o código

battery_remaining: check for division by zero

Aaron Marcher %!s(int64=7) %!d(string=hai) anos
pai
achega
aa8654795d
Modificáronse 1 ficheiros con 4 adicións e 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;