From 92ded6c6fd4a561e94c424a249fdba916f254bda Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Mon, 4 Jan 2016 16:53:39 -0800 Subject: [PATCH] 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. --- audio/out/ao_wasapi_utils.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index c68b276120..39dbbb2cae 100644 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -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));