瀏覽代碼

Fix `InputEventJoypadButton::as_text` crash for invalid button index

Haoyu Qiu 4 年之前
父節點
當前提交
c727d40507
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      core/input/input_event.cpp

+ 1 - 1
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]);
 	}