summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2021-01-29 13:04:01 -0800
committerSam Lantinga <slouken@libsdl.org>2021-01-29 13:04:01 -0800
commitabee814d67613e5365e718886e4aa13e71366928 (patch)
tree266232ad7488a558367dd23a736118fce18d3fa0
parent46db7acbaa90cc6a76fefb5afec46eb0a114f492 (diff)
downloadsdl-abee814d67613e5365e718886e4aa13e71366928.tar.gz
Fixed crash if the GameCube controller hasn't been opened yet
-rw-r--r--src/joystick/hidapi/SDL_hidapi_gamecube.c4
1 files changed, 4 insertions, 0 deletions
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( \