From 1272ce4bb96f6750ea4b2fe698357630c86a1d57 Mon Sep 17 00:00:00 2001 From: o9000 Date: Sun, 1 Feb 2015 23:42:05 +0000 Subject: [PATCH] Fix issue 442: do not overflow when processing buggy battery input git-svn-id: http://tint2.googlecode.com/svn/trunk@682 121b4492-b84c-0410-8b4c-0d4edfb3f3cc --- src/battery/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battery/battery.c b/src/battery/battery.c index 2b4780e..8b5a0eb 100644 --- a/src/battery/battery.c +++ b/src/battery/battery.c @@ -387,7 +387,7 @@ void update_battery() { battery_state.time.seconds = seconds; if(energy_full > 0) - new_percentage = (energy_now*100)/energy_full; + new_percentage = ((energy_now <= energy_full ? energy_now : energy_full) * 100) / energy_full; if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) { tint_exec(battery_low_cmd);