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
This commit is contained in:
William Wilgus 2019-09-24 23:40:38 -05:00
parent 60825970e9
commit 5afdcdd460
2 changed files with 2 additions and 2 deletions

View file

@ -107,7 +107,7 @@ void screen_put_iconxy(struct screen * display,
const int is_rtl = lang_is_rtl();
const struct bitmap *iconset;
if (icon == Icon_NOICON)
if (icon <= Icon_NOICON)
{
if (is_rtl)
xpos = display->getwidth() - xpos - width;

View file

@ -84,7 +84,7 @@ static const unsigned short icons[Icon_Last_Themeable] = {
extern void screen_put_iconxy(struct screen * screen,
int x, int y, enum themable_icons icon)
{
if (icon == Icon_NOICON)
if (icon <= Icon_NOICON)
screen->putchar(x, y, ' ');
else if (icon >= Icon_Last_Themeable)
screen->putchar(x, y, old_Icon_Unknown);