mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-20 15:51:07 +01:00
Fix potential memory leak in SDL_HIDAPI_HapticOpenFromJoystick() on error
This commit is contained in:
committed by
Sam Lantinga
parent
2d9fca46c6
commit
6cf03ca729
@@ -147,6 +147,7 @@ bool SDL_HIDAPI_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystic
|
|||||||
haptic->neffects = device->driver->NumEffects(device);
|
haptic->neffects = device->driver->NumEffects(device);
|
||||||
haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
|
haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
|
||||||
if (haptic->effects == NULL) {
|
if (haptic->effects == NULL) {
|
||||||
|
SDL_free(list_node);
|
||||||
device->driver->Close(device);
|
device->driver->Close(device);
|
||||||
SDL_free(device);
|
SDL_free(device);
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
|
|||||||
Reference in New Issue
Block a user