diff options
author | William Wilgus <me.theuser@yahoo.com> | 2018-12-05 23:44:47 -0600 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-07-10 06:09:46 +0200 |
commit | a980c0b3e51466d041f1a05a1bd2e7afd6a8efe8 (patch) | |
tree | 10cb7b4ca7285aa1073a2847c737c0ac53841d20 /apps/gui | |
parent | fc7a45853be2e090110ef4b5e30a158db78d816e (diff) | |
download | rockbox-a980c0b3e51466d041f1a05a1bd2e7afd6a8efe8.tar.gz rockbox-a980c0b3e51466d041f1a05a1bd2e7afd6a8efe8.zip |
Fix possible truncation statusbar.c->gui_statusbar_icon_battery
limit percent range to 0 - 100%
Change-Id: I46477cdfe954fb1ea3e6158949c920769447762e
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/statusbar.c | 7 |
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, | |||
427 | /* show graphical animation when charging instead of numbers */ | 427 | /* show graphical animation when charging instead of numbers */ |
428 | if ((global_settings.battery_display) && | 428 | if ((global_settings.battery_display) && |
429 | (charge_state != CHARGING) && | 429 | (charge_state != CHARGING) && |
430 | (percent > -1)) { | 430 | (percent > -1) && |
431 | (percent <= 100)) { | ||
431 | #else /* all others */ | 432 | #else /* all others */ |
432 | if (global_settings.battery_display && (percent > -1)) { | 433 | if (global_settings.battery_display && (percent > -1) && (percent <= 100)) { |
433 | #endif | 434 | #endif |
434 | /* Numeric display */ | 435 | /* Numeric display */ |
435 | display->setfont(FONT_SYSFIXED); | 436 | display->setfont(FONT_SYSFIXED); |
@@ -465,7 +466,7 @@ static void gui_statusbar_icon_battery(struct screen * display, int percent, | |||
465 | #endif | 466 | #endif |
466 | } | 467 | } |
467 | 468 | ||
468 | if (percent == -1) { | 469 | if (percent == -1 || percent > 100) { |
469 | display->setfont(FONT_SYSFIXED); | 470 | display->setfont(FONT_SYSFIXED); |
470 | display->putsxy(STATUSBAR_BATTERY_X_POS + STATUSBAR_BATTERY_WIDTH / 2 | 471 | display->putsxy(STATUSBAR_BATTERY_X_POS + STATUSBAR_BATTERY_WIDTH / 2 |
471 | - 4, STATUSBAR_Y_POS, "?"); | 472 | - 4, STATUSBAR_Y_POS, "?"); |