Fix leak of AudioDeviceID array due to an early return in AudioDeviceMac::GetNumberDevices(): Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc:1586:3: warning: Potential leak of memory pointed to by 'deviceIds' WEBRTC_CA_RETURN_ON_ERR(AudioObjectGetPropertyData(kAudioObjectSystemObject, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc:30:7: note: expanded from macro 'WEBRTC_CA_RETURN_ON_ERR' logCAMsg(rtc::LS_ERROR, "Error in " #expr, (const char*)&err); \ ^~~~~~~~ We can use RAII with std::unique_ptr<>() to fix the leak and remove manual release of the memory using this technique: <https://www.codeproject.com/Articles/820931/Using-std-unique-ptr-RAII-with-malloc-and-free>
<rdar://problem/40692824>
Created attachment 341679 [details] Patch v1
Comment on attachment 341679 [details] Patch v1 Can't we use std::make_unique?
(In reply to Alex Christensen from comment #3) > Comment on attachment 341679 [details] > Patch v1 > > Can't we use std::make_unique? I was aiming to change the code as little as possible, but yes we can! New patch forthcoming.
Created attachment 341681 [details] Patch v2
Created attachment 341684 [details] Patch v3 Remove 'const' from 'numberDevices' since it used in an in-out context in AudioObjectGetPropertyData().
Comment on attachment 341684 [details] Patch v3 Clearing flags on attachment: 341684 Committed r232365: <https://trac.webkit.org/changeset/232365>
All reviewed patches have been landed. Closing bug.