From b2177fccbc7a27996b7154e5e7ddccbb7d9ead92 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 7 Feb 2022 02:47:32 -0800 Subject: [PATCH] Core Audio input: Fix channel config, and a leak Channel config should not contain duplicate channels, or unsupported channels. Also fix a memory leak from not freeing the AudioChannelLayout structure allocated previously. Signed-off-by: Christopher Snowhill --- Plugins/CoreAudio/CoreAudioDecoder.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Plugins/CoreAudio/CoreAudioDecoder.m b/Plugins/CoreAudio/CoreAudioDecoder.m index cb64eb6a9..489a69fbe 100644 --- a/Plugins/CoreAudio/CoreAudioDecoder.m +++ b/Plugins/CoreAudio/CoreAudioDecoder.m @@ -220,12 +220,24 @@ static SInt64 getSizeProc(void *clientData) { uint32_t config = 0; for(uint32_t i = 0; i < acl->mNumberChannelDescriptions; ++i) { int channelNumber = ffat_get_channel_id(acl->mChannelDescriptions[i].mChannelLabel); - if(channelNumber >= 0) + if(channelNumber >= 0) { + if(config & (1 << channelNumber)) { + free(acl); + err = ExtAudioFileDispose(_in); + return NO; + } config |= 1 << channelNumber; + } else { + free(acl); + err = ExtAudioFileDispose(_in); + return NO; + } } channelConfig = config; + free(acl); + bitrate = (_bitrate + 500) / 1000; CFStringRef formatName;