Fix potential memory leak in SDL_HIDAPI_HapticOpenFromJoystick() on error

This commit is contained in:
Petar Popovic
2026-03-01 17:34:24 +01:00
committed by Sam Lantinga
parent 2d9fca46c6
commit 6cf03ca729

View File

@@ -147,6 +147,7 @@ bool SDL_HIDAPI_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystic
haptic->neffects = device->driver->NumEffects(device);
haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
SDL_free(list_node);
device->driver->Close(device);
SDL_free(device);
return SDL_OutOfMemory();