Check the result of CFStringGetCStringPtr before assigning it to an std::string.

This commit is contained in:
casey langen 2019-01-17 19:49:57 -08:00
parent 926b5bebea
commit b2c6b34a7b

View File

@ -38,7 +38,7 @@
#include <iostream>
#include <vector>
#define BUFFER_COUNT 24
#define BUFFER_COUNT 24
#define PREF_DEVICE_ID "device_id"
using namespace musik::core::sdk;
@ -392,7 +392,10 @@ IDeviceList* CoreAudioOut::GetDeviceList() {
CFStringRef deviceUid;
if (AudioObjectGetPropertyData(deviceId, &uidAddress, 0, NULL, &propsize, &deviceUid) == 0) {
deviceIdStr = CFStringGetCStringPtr(deviceUid, kCFStringEncodingUTF8);
const char* cstr = CFStringGetCStringPtr(deviceUid, kCFStringEncodingUTF8);
if (cstr) {
deviceIdStr = cstr;
}
}
if (deviceNameStr.size() && deviceIdStr.size()) {