From 452c3634d4cda3dfaf4e8e419da65bc5d7b78959 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 24 Aug 2026 16:31:46 -0700 Subject: [PATCH] Fixed two cases where joystick/haptic objects should be marked invalid on error during open. --- src/haptic/SDL_haptic.c | 1 + src/joystick/hidapi/SDL_hidapijoystick.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index 577502c922..24ff11ccfe 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -367,6 +367,7 @@ SDL_Haptic *SDL_OpenHapticFromJoystick(SDL_Joystick *joystick) if (SDL_HIDAPI_JoystickIsHaptic(joystick)) { if (!SDL_HIDAPI_HapticOpenFromJoystick(haptic, joystick)) { SDL_SetError("Haptic: SDL_HIDAPI_HapticOpenFromJoystick failed."); + SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, false); SDL_free(haptic); SDL_UnlockJoysticks(); return NULL; diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index c79d9c31dd..d59b962b15 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -950,6 +950,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } if (!device->name) { + SDL_SetObjectValid(device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, false); SDL_free(device->manufacturer_string); SDL_free(device->product_string); SDL_free(device->serial);