summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2021-06-13 10:05:55 +0200
committerGitHub <noreply@github.com>2021-06-13 10:05:55 +0200
commitb536bac28e66c31e789029852902f55de491d49f (patch)
tree110d7036e3cedc8ae771f335af5d7039be67663e
parentccaefbce551fe6c1a0016b2f0407b6323ab8c601 (diff)
parentc727d40507fa66dcff083518f5b88da7c6b34134 (diff)
Merge pull request #49556 from timothyqiu/joypad-button-range-check
Fix `InputEventJoypadButton::as_text` crash for invalid button index
-rw-r--r--core/input/input_event.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 6f063c217f..9c1cf15342 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]);
}