From 6cf03ca729b0dc97c559219568f7bbb3e3e84f86 Mon Sep 17 00:00:00 2001
From: Petar Popovic <[EMAIL REDACTED]>
Date: Sun, 1 Mar 2026 17:34:24 +0100
Subject: [PATCH] Fix potential memory leak in
SDL_HIDAPI_HapticOpenFromJoystick() on error
---
src/haptic/hidapi/SDL_hidapihaptic.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/haptic/hidapi/SDL_hidapihaptic.c b/src/haptic/hidapi/SDL_hidapihaptic.c
index fbcbd0f0cf335..f9985fc136753 100644
--- a/src/haptic/hidapi/SDL_hidapihaptic.c
+++ b/src/haptic/hidapi/SDL_hidapihaptic.c
@@ -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();