mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-22 23:25:34 +00:00
coreaudio: obey MAX_CHANNELS when creating devices
fixes #57, which was caused by a buffer overflow with devices with more than MAX_CHANNELS channels
This commit is contained in:
parent
2e064bfca8
commit
99f5b4e4b6
|
@ -280,7 +280,10 @@ static int from_coreaudio_layout(const AudioChannelLayout *ca_layout, struct Sou
|
||||||
switch (ca_layout->mChannelLayoutTag) {
|
switch (ca_layout->mChannelLayoutTag) {
|
||||||
case kAudioChannelLayoutTag_UseChannelDescriptions:
|
case kAudioChannelLayoutTag_UseChannelDescriptions:
|
||||||
{
|
{
|
||||||
layout->channel_count = ca_layout->mNumberChannelDescriptions;
|
layout->channel_count = soundio_int_min(
|
||||||
|
SOUNDIO_MAX_CHANNELS,
|
||||||
|
ca_layout->mNumberChannelDescriptions
|
||||||
|
);
|
||||||
for (int i = 0; i < layout->channel_count; i += 1) {
|
for (int i = 0; i < layout->channel_count; i += 1) {
|
||||||
layout->channels[i] = from_channel_descr(&ca_layout->mChannelDescriptions[i]);
|
layout->channels[i] = from_channel_descr(&ca_layout->mChannelDescriptions[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue