From 5cf67f00d0e4d157fb08ac56cb9d8066c57a7be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Mon, 31 May 2021 10:23:58 +0200 Subject: [PATCH] dinput: Free axis_map when joystick device is freed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=36263 Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/dinput/joystick.c | 11 +++++++++++ dlls/dinput/joystick_linux.c | 2 +- dlls/dinput/joystick_linuxinput.c | 2 +- dlls/dinput/joystick_osx.c | 2 +- dlls/dinput/joystick_private.h | 2 ++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index a68c4df20e6..8ea7850621c 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -534,6 +534,17 @@ HRESULT WINAPI JoystickWGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, return DI_OK; } + +ULONG WINAPI JoystickWGenericImpl_Release(LPDIRECTINPUTDEVICE8W iface) +{ + JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface); + void *axis_map = This->axis_map; + ULONG res = IDirectInputDevice2WImpl_Release(iface); + if (!res) HeapFree(GetProcessHeap(), 0, axis_map); + return res; +} + + /****************************************************************************** * GetObjectInfo : get object info */ diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 5a88e643e07..3215978c995 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -786,7 +786,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_AddRef, - IDirectInputDevice2WImpl_Release, + JoystickWGenericImpl_Release, JoystickWGenericImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, JoystickLinuxWImpl_GetProperty, diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 488e9c04759..2b970271ec3 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -1231,7 +1231,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_AddRef, - IDirectInputDevice2WImpl_Release, + JoystickWGenericImpl_Release, JoystickWGenericImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, JoystickWImpl_GetProperty, diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 6d37a476380..27a47b07639 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -1484,7 +1484,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_AddRef, - IDirectInputDevice2WImpl_Release, + JoystickWGenericImpl_Release, JoystickWGenericImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, JoystickWImpl_GetProperty, diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index 78d5d721808..874bf3e69a7 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -59,6 +59,8 @@ DWORD joystick_map_pov(const POINTL *p) DECLSPEC_HIDDEN; BOOL device_disabled_registry(const char* name) DECLSPEC_HIDDEN; +ULONG WINAPI JoystickWGenericImpl_Release(LPDIRECTINPUTDEVICE8W iface); + HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;