Fixed two cases where joystick/haptic objects should be marked invalid on error during open.

This commit is contained in:
Sam Lantinga
2026-08-24 16:31:46 -07:00
parent 40e1357e29
commit 452c3634d4
2 changed files with 2 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);