summaryrefslogtreecommitdiff
path: root/modules/devices/battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/devices/battery.c')
-rw-r--r--modules/devices/battery.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/devices/battery.c b/modules/devices/battery.c
index 37416dbb..09c84eeb 100644
--- a/modules/devices/battery.c
+++ b/modules/devices/battery.c
@@ -174,7 +174,10 @@ __scan_battery_acpi(void)
}
if (g_str_equal(present, "yes")) {
- charge_rate = atof(remaining) / atof(capacity);
+ if (remaining && capacity)
+ charge_rate = atof(remaining) / atof(capacity);
+ else
+ charge_rate = 0;
battery_list = h_strdup_cprintf("\n[Battery: %s]\n"
"State=%s (load: %s)\n"