Преглед изворни кода

battery_remaining: check for division by zero

Aaron Marcher пре 7 година
родитељ
комит
aa8654795d
1 измењених фајлова са 4 додато и 0 уклоњено
  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;