From 5f07347e4f4c1d9175cbd8fdcd7c662788c3910f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 4 Mar 2025 11:41:25 -0800 Subject: [PATCH] Fixed crash unplugging a HIDAPI controller --- src/joystick/hidapi/SDL_hidapijoystick.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index bec9c90714..aec6463347 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -1135,12 +1135,13 @@ check_removed: goto check_removed; } else { HIDAPI_DelDevice(device); + device = NULL; // Update the device list again in case this device comes back SDL_HIDAPI_change_count = 0; } } - if (device->broken && device->parent) { + if (device && device->broken && device->parent) { HIDAPI_DelDevice(device->parent); // We deleted a different device here, restart the loop