summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2018-12-05 23:44:47 -0600
committerWilliam Wilgus <me.theuser@yahoo.com>2019-07-10 06:09:46 +0200
commita980c0b3e51466d041f1a05a1bd2e7afd6a8efe8 (patch)
tree10cb7b4ca7285aa1073a2847c737c0ac53841d20
parentfc7a45853be2e090110ef4b5e30a158db78d816e (diff)
downloadrockbox-a980c0b.tar.gz
rockbox-a980c0b.zip
Fix possible truncation statusbar.c->gui_statusbar_icon_battery
limit percent range to 0 - 100% Change-Id: I46477cdfe954fb1ea3e6158949c920769447762e
-rw-r--r--apps/gui/statusbar.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index 84de16987f..30dad95509 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -427,9 +427,10 @@ static void gui_statusbar_icon_battery(struct screen * display, int percent,
/* show graphical animation when charging instead of numbers */
if ((global_settings.battery_display) &&
(charge_state != CHARGING) &&
- (percent > -1)) {
+ (percent > -1) &&
+ (percent <= 100)) {
#else /* all others */
- if (global_settings.battery_display && (percent > -1)) {
+ if (global_settings.battery_display && (percent > -1) && (percent <= 100)) {
#endif
/* Numeric display */
display->setfont(FONT_SYSFIXED);
@@ -465,7 +466,7 @@ static void gui_statusbar_icon_battery(struct screen * display, int percent,
#endif
}
- if (percent == -1) {
+ if (percent == -1 || percent > 100) {
display->setfont(FONT_SYSFIXED);
display->putsxy(STATUSBAR_BATTERY_X_POS + STATUSBAR_BATTERY_WIDTH / 2
- 4, STATUSBAR_Y_POS, "?");