diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index e47cad440..b4d5ffbee 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -2178,6 +2178,13 @@ static void CursorEnterCallback(GLFWwindow *window, int enter) // GLFW3: Joystick connected/disconnected callback 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) { // WARNING: If glfwGetJoystickName() is longer than MAX_GAMEPAD_NAME_LENGTH,