From abee814d67613e5365e718886e4aa13e71366928 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 29 Jan 2021 13:04:01 -0800 Subject: Fixed crash if the GameCube controller hasn't been opened yet --- src/joystick/hidapi/SDL_hidapi_gamecube.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c index 83db51fbc..9d6ddd80b 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -253,6 +253,10 @@ HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device, SDL_Driver } joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]); + if (!joystick) { + /* Hasn't been opened yet, skip */ + return; + } #define READ_BUTTON(off, flag, button) \ SDL_PrivateJoystickButton( \ -- cgit v1.2.1