added bounds check

This commit is contained in:
CrackedPixel 2026-03-03 22:22:54 -06:00
parent e1959a4e5c
commit 406ad3aedc

View File

@ -2178,6 +2178,13 @@ 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)
{
// WARNING: If jid is higher than maximum supported joysticks, just return. This
// prevents an out-of-bounds crash on linux when connecting a gamepad to a running app
return;
}
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,