Add check for converting negative SDL_GameControllerButton to glyph

A SDL_GameControllerButton below 0 is out of array bounds, so that
should trip the assert and return GLYPH_UNKNOWN just like when the
value is too high.
This commit is contained in:
Dav999 2025-04-16 21:12:51 +02:00 committed by Ethan Lee
parent f715897fdd
commit 3320ee5962

View file

@ -274,7 +274,7 @@ const char* BUTTONGLYPHS_get_wasd_text(void)
const char* BUTTONGLYPHS_sdlbutton_to_glyph(const SDL_GameControllerButton button)
{
if (button > SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
if (button < 0 || button > SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
{
SDL_assert(0 && "Unhandled button!");
return glyph[GLYPH_UNKNOWN];