From 50971577e4a4f57a2c677d8a5f26c951caed68f2 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 11 Nov 2021 22:35:41 -0600 Subject: [PATCH] dinput: Fix memory leak when SDL_DINPUT_JoystickPresent() returns true --- src/joystick/windows/SDL_dinputjoystick.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index 16deb512a..614c7de50 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -558,6 +558,7 @@ EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext Uint16 vendor = 0; Uint16 product = 0; LPDIRECTINPUTDEVICE8 device = NULL; + BOOL result = DIENUM_CONTINUE; /* We are only supporting HID devices. */ CHECK((pDeviceInstance->dwDevType & DIDEVTYPE_HID) != 0); @@ -567,7 +568,7 @@ EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext if (vendor == pData->vendor && product == pData->product) { pData->present = SDL_TRUE; - return DIENUM_STOP; /* get next device, please */ + result = DIENUM_STOP; /* found it */ } err: @@ -575,7 +576,7 @@ err: IDirectInputDevice8_Release(device); } - return DIENUM_CONTINUE; /* get next device, please */ + return result; #undef CHECK }