dinput: Fix memory leak when SDL_DINPUT_JoystickPresent() returns true

This commit is contained in:
Cameron Gutman 2021-11-11 22:35:41 -06:00
parent ed05a0e9e7
commit 50971577e4
1 changed files with 3 additions and 2 deletions

View File

@ -558,6 +558,7 @@ EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext
Uint16 vendor = 0; Uint16 vendor = 0;
Uint16 product = 0; Uint16 product = 0;
LPDIRECTINPUTDEVICE8 device = NULL; LPDIRECTINPUTDEVICE8 device = NULL;
BOOL result = DIENUM_CONTINUE;
/* We are only supporting HID devices. */ /* We are only supporting HID devices. */
CHECK((pDeviceInstance->dwDevType & DIDEVTYPE_HID) != 0); CHECK((pDeviceInstance->dwDevType & DIDEVTYPE_HID) != 0);
@ -567,7 +568,7 @@ EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext
if (vendor == pData->vendor && product == pData->product) { if (vendor == pData->vendor && product == pData->product) {
pData->present = SDL_TRUE; pData->present = SDL_TRUE;
return DIENUM_STOP; /* get next device, please */ result = DIENUM_STOP; /* found it */
} }
err: err:
@ -575,7 +576,7 @@ err:
IDirectInputDevice8_Release(device); IDirectInputDevice8_Release(device);
} }
return DIENUM_CONTINUE; /* get next device, please */ return result;
#undef CHECK #undef CHECK
} }