Merge pull request #49556 from timothyqiu/joypad-button-range-check

Fix `InputEventJoypadButton::as_text` crash for invalid button index
This commit is contained in:
Rémi Verschelde 2021-06-13 10:05:55 +02:00 committed by GitHub
commit b536bac28e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -1023,7 +1023,7 @@ static const char *_joy_button_descriptions[JOY_BUTTON_SDL_MAX] = {
String InputEventJoypadButton::as_text() const { String InputEventJoypadButton::as_text() const {
String text = "Joypad Button " + itos(button_index); String text = "Joypad Button " + itos(button_index);
if (button_index < JOY_BUTTON_SDL_MAX) { if (button_index >= 0 && button_index < JOY_BUTTON_SDL_MAX) {
text += vformat(" (%s)", _joy_button_descriptions[button_index]); text += vformat(" (%s)", _joy_button_descriptions[button_index]);
} }