ao_wasapi: Don't leak the default device's ID when listing devices

Also remove unused variable.
This commit is contained in:
Diogo Franco (Kovensky) 2013-07-20 20:10:24 -03:00 committed by wm4
parent 32cb190855
commit 56274c6664
1 changed files with 4 additions and 3 deletions

View File

@ -641,7 +641,7 @@ static HRESULT enumerate_with_state(char *header, int status, int with_id) {
IMMDeviceCollection *pDevices = NULL;
IMMDevice *pDevice = NULL;
IPropertyStore *pProps = NULL;
LPWSTR idStr = NULL;
char *defid = NULL;
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
@ -653,7 +653,7 @@ static HRESULT enumerate_with_state(char *header, int status, int with_id) {
&pDevice);
EXIT_ON_ERROR(hr)
char *defid = get_device_id(pDevice);
defid = get_device_id(pDevice);
SAFE_RELEASE(pDevice, IMMDevice_Release(pDevice));
@ -690,12 +690,13 @@ static HRESULT enumerate_with_state(char *header, int status, int with_id) {
free(id);
SAFE_RELEASE(pDevice, IMMDevice_Release(pDevice));
}
free(defid);
SAFE_RELEASE(pDevices, IMMDeviceCollection_Release(pDevices));
SAFE_RELEASE(pEnumerator, IMMDeviceEnumerator_Release(pEnumerator));
return hr;
exit_label:
CoTaskMemFree(idStr);
free(defid);
SAFE_RELEASE(pProps, IPropertyStore_Release(pProps));
SAFE_RELEASE(pDevice, IMMDevice_Release(pDevice));
SAFE_RELEASE(pDevices, IMMDeviceCollection_Release(pDevices));