From 37b788c1c882b40fcefa774034c4422858167651 Mon Sep 17 00:00:00 2001 From: Dav999 Date: Wed, 16 Apr 2025 21:12:51 +0200 Subject: [PATCH] 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. --- desktop_version/src/ButtonGlyphs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop_version/src/ButtonGlyphs.cpp b/desktop_version/src/ButtonGlyphs.cpp index 229a0e32..3060fd42 100644 --- a/desktop_version/src/ButtonGlyphs.cpp +++ b/desktop_version/src/ButtonGlyphs.cpp @@ -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];