[backend/GLFW] Added bounds check (#5621)

* added bounds check

* update from PR feedback
This commit is contained in:
Thomas Anderson
2026-03-04 01:40:15 -06:00
committed by GitHub
parent 28288fafb1
commit de720a8d4c

View File

@ -2178,6 +2178,8 @@ static void CursorEnterCallback(GLFWwindow *window, int enter)
// GLFW3: Joystick connected/disconnected callback // GLFW3: Joystick connected/disconnected callback
static void JoystickCallback(int jid, int event) static void JoystickCallback(int jid, int event)
{ {
if (jid < MAX_GAMEPADS)
{
if (event == GLFW_CONNECTED) if (event == GLFW_CONNECTED)
{ {
// WARNING: If glfwGetJoystickName() is longer than MAX_GAMEPAD_NAME_LENGTH, // WARNING: If glfwGetJoystickName() is longer than MAX_GAMEPAD_NAME_LENGTH,
@ -2189,6 +2191,7 @@ static void JoystickCallback(int jid, int event)
{ {
memset(CORE.Input.Gamepad.name[jid], 0, MAX_GAMEPAD_NAME_LENGTH); memset(CORE.Input.Gamepad.name[jid], 0, MAX_GAMEPAD_NAME_LENGTH);
} }
}
} }
#ifdef _WIN32 #ifdef _WIN32