From c727d40507fa66dcff083518f5b88da7c6b34134 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sun, 13 Jun 2021 13:53:11 +0800 Subject: [PATCH] Fix `InputEventJoypadButton::as_text` crash for invalid button index --- core/input/input_event.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 6f063c217f2..9c1cf15342a 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -1023,7 +1023,7 @@ static const char *_joy_button_descriptions[JOY_BUTTON_SDL_MAX] = { String InputEventJoypadButton::as_text() const { 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]); }