From 378aaf23ae93ed12197a5cd582fcef956742a4af Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 26 Dec 2021 18:08:53 -0800 Subject: [PATCH] Clean up several CFStringRef leaks --- Audio/Output/OutputCoreAudio.m | 14 +++++++++++--- Preferences/Preferences/OutputsArrayController.m | 10 ++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Audio/Output/OutputCoreAudio.m b/Audio/Output/OutputCoreAudio.m index 6875a9d8f..e3a75ec66 100644 --- a/Audio/Output/OutputCoreAudio.m +++ b/Audio/Output/OutputCoreAudio.m @@ -135,10 +135,12 @@ static void Sound_Renderer(void *userData, AudioQueueRef queue, AudioQueueBuffer err = AudioQueueStop(audioQueue, true); if (err) { DLog(@"Error stopping stream to set device"); + CFRelease(theDeviceUID); return err; } primed = NO; err = AudioQueueSetProperty(audioQueue, kAudioQueueProperty_CurrentDevice, &theDeviceUID, sizeof(theDeviceUID)); + CFRelease(theDeviceUID); if (running) [self start]; } @@ -240,15 +242,21 @@ static void Sound_Renderer(void *userData, AudioQueueRef queue, AudioQueueBuffer theAddress.mSelector = kAudioDevicePropertyStreamConfiguration; __Verify_noErr(AudioObjectGetPropertyDataSize(devids[i], &theAddress, 0, NULL, &propsize)); - if (propsize < sizeof(UInt32)) continue; + if (propsize < sizeof(UInt32)) { + CFRelease(name); + continue; + } AudioBufferList * bufferList = (AudioBufferList *) malloc(propsize); __Verify_noErr(AudioObjectGetPropertyData(devids[i], &theAddress, 0, NULL, &propsize, bufferList)); UInt32 bufferCount = bufferList->mNumberBuffers; free(bufferList); - if (!bufferCount) continue; - + if (!bufferCount) { + CFRelease(name); + continue; + } + BOOL stop = NO; block([NSString stringWithString:(__bridge NSString *)name], devids[i], diff --git a/Preferences/Preferences/OutputsArrayController.m b/Preferences/Preferences/OutputsArrayController.m index 306631027..cc13206c1 100644 --- a/Preferences/Preferences/OutputsArrayController.m +++ b/Preferences/Preferences/OutputsArrayController.m @@ -75,14 +75,20 @@ theAddress.mSelector = kAudioDevicePropertyStreamConfiguration; __Verify_noErr(AudioObjectGetPropertyDataSize(devids[i], &theAddress, 0, NULL, &propsize)); - if (propsize < sizeof(UInt32)) continue; + if (propsize < sizeof(UInt32)) { + CFRelease(name); + continue; + } AudioBufferList * bufferList = (AudioBufferList *) malloc(propsize); __Verify_noErr(AudioObjectGetPropertyData(devids[i], &theAddress, 0, NULL, &propsize, bufferList)); UInt32 bufferCount = bufferList->mNumberBuffers; free(bufferList); - if (!bufferCount) continue; + if (!bufferCount) { + CFRelease(name); + continue; + } BOOL stop = NO; block([NSString stringWithString:(__bridge NSString *)name],