ao_wasapi: alloc later to avoid free on error

In get_device_desc, don't alloc the return value until we know there
wasn't an error.
This commit is contained in:
Kevin Mitchell 2016-01-04 16:53:39 -08:00
parent 3d03298e86
commit 92ded6c6fd
1 changed files with 1 additions and 2 deletions

View File

@ -798,14 +798,13 @@ exit_label:
static struct device_desc *get_device_desc(struct mp_log *l, IMMDevice *pDevice)
{
struct device_desc *d = talloc_zero(NULL, struct device_desc);
LPWSTR deviceID;
HRESULT hr = IMMDevice_GetId(pDevice, &deviceID);
if (FAILED(hr)) {
mp_err(l, "Failed getting device id: %s\n", mp_HRESULT_to_str(hr));
talloc_free(d);
return NULL;
}
struct device_desc *d = talloc_zero(NULL, struct device_desc);
d->deviceID = talloc_memdup(d, deviceID,
(wcslen(deviceID) + 1) * sizeof(wchar_t));
SAFE_RELEASE(deviceID, CoTaskMemFree(deviceID));