Skip to content

Commit 9d7fb42

Browse files
committed
check totalCapacity before use it as a divisor
1 parent a270702 commit 9d7fb42

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

netbsd/Platform.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,9 @@ void Platform_getBattery(double* percent, ACPresence* isOnAC) {
512512
*isOnAC = isConnected ? AC_PRESENT : AC_ABSENT;
513513
}
514514
}
515-
516-
*percent = ((double)totalCharge / (double)totalCapacity) * 100.0;
515+
if (totalCapacity != 0){
516+
*percent = ((double)totalCharge / (double)totalCapacity) * 100.0;
517+
}
517518

518519
error:
519520
if (fd != -1)

0 commit comments

Comments
 (0)