[PATCH 4/5] dinput: Return E_OUTOFMEMORY on allocation failure in hid_joystick_create_device().

Zebediah Figura zfigura at codeweavers.com
Sun May 15 20:46:13 CDT 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/dinput/joystick_hid.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 4e083871ba4..bf7f090aca9 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -2066,7 +2066,11 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi
                                            &impl->caps, &instance, dinput->dwVersion ))
             hr = DIERR_DEVICENOTREG;
     }
-    if (hr != DI_OK) goto failed;
+    if (hr != DI_OK)
+    {
+        IDirectInputDevice_Release( &impl->base.IDirectInputDevice8W_iface );
+        return hr;
+    }
 
     impl->base.instance = instance;
     impl->base.caps.dwDevType = instance.dwDevType;
@@ -2143,7 +2147,7 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi
 
 failed:
     IDirectInputDevice_Release( &impl->base.IDirectInputDevice8W_iface );
-    return hr;
+    return E_OUTOFMEMORY;
 }
 
 static HRESULT WINAPI hid_joystick_effect_QueryInterface( IDirectInputEffect *iface, REFIID iid, void **out )
-- 
2.35.1




More information about the wine-devel mailing list