From 466f4fb1db62e890f24eca67ea5681bb84c861ac Mon Sep 17 00:00:00 2001 From: "lorthiois@bbsoft.fr" Date: Sat, 16 May 2009 15:43:48 +0000 Subject: [PATCH] fixed possible segfault git-svn-id: http://tint2.googlecode.com/svn/trunk@76 121b4492-b84c-0410-8b4c-0d4edfb3f3cc --- src/battery/battery.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/battery/battery.c b/src/battery/battery.c index 7bd6f94..6a6877e 100644 --- a/src/battery/battery.c +++ b/src/battery/battery.c @@ -100,7 +100,8 @@ void update_battery(struct batstate *data) { seconds -= 60 * data->time.minutes; data->time.seconds = seconds; - new_percentage = (energy_now*100)/energy_full; + if(energy_full > 0) + new_percentage = (energy_now*100)/energy_full; if(battery_low_status != 0 && battery_low_status == new_percentage && data->percentage > new_percentage) { printf("battery low, executing: %s\n", battery_low_cmd);