SDL: Fixed memory leak in XInput code (d5896)

From d5896f9010bfc9465fa07c4a2d8a2e3c5f7d2fac Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 6 Nov 2023 00:40:19 -0800
Subject: [PATCH] Fixed memory leak in XInput code

Fixes https://github.com/libsdl-org/SDL/issues/3597

(cherry picked from commit 3e4d7e48b0a87b2c1df26ad62c8152ba6c064024)
---
 src/joystick/windows/SDL_xinputjoystick.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c
index 087161ce107a..0b288f091e70 100644
--- a/src/joystick/windows/SDL_xinputjoystick.c
+++ b/src/joystick/windows/SDL_xinputjoystick.c
@@ -552,6 +552,12 @@ void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick)
 
 void SDL_XINPUT_JoystickQuit(void)
 {
+    int iuserid;
+
+    for (iuserid = 0; iuserid < XUSER_MAX_COUNT; ++iuserid) {
+        DelXInputDevice(iuserid);
+    }
+
     if (s_bXInputEnabled) {
         WIN_UnloadXInputDLL();
     }