소스 검색

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;