From a980c0b3e51466d041f1a05a1bd2e7afd6a8efe8 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 5 Dec 2018 23:44:47 -0600 Subject: Fix possible truncation statusbar.c->gui_statusbar_icon_battery limit percent range to 0 - 100% Change-Id: I46477cdfe954fb1ea3e6158949c920769447762e --- apps/gui/statusbar.c | 7 ++++--- 1 file 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, "?"); -- cgit v1.2.3