check alcGetString return pointers

This commit is contained in:
RipleyTom 2021-02-18 06:59:03 +01:00 committed by Megamouse
parent b86ec2ffcf
commit 5129d0da45

View File

@ -26,18 +26,22 @@ void microphone_creator::refresh_list()
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE) if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE)
{ {
const char* devices = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER); if (const char* devices = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER); devices != nullptr)
while (*devices != 0)
{ {
m_microphone_list.append(qstr(devices)); while (*devices != 0)
devices += strlen(devices) + 1; {
m_microphone_list.append(qstr(devices));
devices += strlen(devices) + 1;
}
} }
} }
else else
{ {
// Without enumeration we can only use one device // Without enumeration we can only use one device
m_microphone_list.append(qstr(alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER))); if (const char* device = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); device != nullptr)
{
m_microphone_list.append(qstr(device));
}
} }
} }