diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-09-24 23:40:38 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-09-24 23:51:12 -0500 |
commit | 5afdcdd46043481675a48891a071dbb1fea1ab4c (patch) | |
tree | 23346110e2b3889ce75b1e2ba654542607527807 | |
parent | 60825970e93b6d9b4aec19456a1e7c142f904bd3 (diff) | |
download | rockbox-5afdcdd46043481675a48891a071dbb1fea1ab4c.tar.gz rockbox-5afdcdd46043481675a48891a071dbb1fea1ab4c.zip |
Bug fix icon.c crashes with negative icon index
The index for Icon_NOICON is -1 which is caught properly
as is icon > Icon_Last_Themeable
But if you pass an index lower than Icon_NOICON screen_put_iconxy()
tries to read memory prior to the iconset resulting in a crash
Change-Id: I415e650932d65214d883a1595e22261f22e776b6
-rw-r--r-- | apps/gui/icon.c | 2 | ||||
-rw-r--r-- | apps/player/icons.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/apps/gui/icon.c b/apps/gui/icon.c index c20f1fe09a..db3ae2c96b 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c | |||
@@ -107,7 +107,7 @@ void screen_put_iconxy(struct screen * display, | |||
107 | const int is_rtl = lang_is_rtl(); | 107 | const int is_rtl = lang_is_rtl(); |
108 | const struct bitmap *iconset; | 108 | const struct bitmap *iconset; |
109 | 109 | ||
110 | if (icon == Icon_NOICON) | 110 | if (icon <= Icon_NOICON) |
111 | { | 111 | { |
112 | if (is_rtl) | 112 | if (is_rtl) |
113 | xpos = display->getwidth() - xpos - width; | 113 | xpos = display->getwidth() - xpos - width; |
diff --git a/apps/player/icons.c b/apps/player/icons.c index 0d160bc967..dc804560f2 100644 --- a/apps/player/icons.c +++ b/apps/player/icons.c | |||
@@ -84,7 +84,7 @@ static const unsigned short icons[Icon_Last_Themeable] = { | |||
84 | extern void screen_put_iconxy(struct screen * screen, | 84 | extern void screen_put_iconxy(struct screen * screen, |
85 | int x, int y, enum themable_icons icon) | 85 | int x, int y, enum themable_icons icon) |
86 | { | 86 | { |
87 | if (icon == Icon_NOICON) | 87 | if (icon <= Icon_NOICON) |
88 | screen->putchar(x, y, ' '); | 88 | screen->putchar(x, y, ' '); |
89 | else if (icon >= Icon_Last_Themeable) | 89 | else if (icon >= Icon_Last_Themeable) |
90 | screen->putchar(x, y, old_Icon_Unknown); | 90 | screen->putchar(x, y, old_Icon_Unknown); |