summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-12-21 12:20:31 -0800
committerChris Robinson <[email protected]>2014-12-21 12:20:31 -0800
commita91bca64f8c32218ec439a79c0e7966d52d746b0 (patch)
tree70831e7de619c98bf639eafc3c8bce7fb7981d1f /Alc
parent13092d94b74da1f42abf5f35e211b33ebf37207a (diff)
Check the PROPVARIANT type before use
Diffstat (limited to 'Alc')
-rw-r--r--Alc/backends/mmdevapi.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index 17f94c23..564dd629 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -134,8 +134,10 @@ static void get_device_name(IMMDevice *device, al_string *name)
hr = IPropertyStore_GetValue(ps, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pvname);
if(FAILED(hr))
WARN("GetValue Device_FriendlyName failed: 0x%08lx\n", hr);
- else
+ else if(pvname.vt == VT_LPWSTR)
al_string_copy_wcstr(name, pvname.pwszVal);
+ else
+ WARN("Unexpected PROPVARIANT type: 0x%04x\n", pvname.vt);
PropVariantClear(&pvname);
IPropertyStore_Release(ps);
@@ -159,8 +161,12 @@ static void get_device_formfactor(IMMDevice *device, EndpointFormFactor *formfac
hr = IPropertyStore_GetValue(ps, &PKEY_AudioEndpoint_FormFactor, &pvform);
if(FAILED(hr))
WARN("GetValue AudioEndpoint_FormFactor failed: 0x%08lx\n", hr);
- else
+ else if(pvform.vt == VT_UI4)
*formfactor = pvform.ulVal;
+ else if(pvform.vt == VT_EMPTY)
+ *formfactor = UnknownFormFactor;
+ else
+ WARN("Unexpected PROPVARIANT type: 0x%04x\n", pvform.vt);
PropVariantClear(&pvform);
IPropertyStore_Release(ps);