From 42b23207566d24411fbd608ad877477cddb22bca Mon Sep 17 00:00:00 2001
From: Mathieu Eyraud <[EMAIL REDACTED]>
Date: Tue, 2 Aug 2022 14:42:25 +0200
Subject: [PATCH] Fix memory leak of children for combined JoyCon
---
src/joystick/hidapi/SDL_hidapijoystick.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 1df6da127bf..63ef7b0436d 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -706,6 +706,7 @@ HIDAPI_DelDevice(SDL_HIDAPI_Device *device)
SDL_free(device->serial);
SDL_free(device->name);
SDL_free(device->path);
+ SDL_free(device->children);
SDL_free(device);
return;
}
@@ -761,6 +762,9 @@ HIDAPI_CreateCombinedJoyCons()
if (combined && combined->driver) {
return SDL_TRUE;
} else {
+ if (!combined) {
+ SDL_free(children);
+ }
return SDL_FALSE;
}
}