summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2016-01-04 16:53:39 -0800
committerKevin Mitchell <kevmitch@gmail.com>2016-01-05 17:47:55 -0800
commit92ded6c6fd4a561e94c424a249fdba916f254bda (patch)
tree0d9b3849516eb8c1300f23f2bc8b71902c647dd0 /audio/out
parent3d03298e86866ce86b4a489d78c7564a275f6a3c (diff)
downloadmpv-92ded6c6fd4a561e94c424a249fdba916f254bda.tar.bz2
mpv-92ded6c6fd4a561e94c424a249fdba916f254bda.tar.xz
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.
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao_wasapi_utils.c3
1 files changed, 1 insertions, 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));