You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: libobs: enum_audio_devices doesn't check its allocation #2862
libobs/audio-monitoring/osx/coreaudio-enum-devices.c.h on master at 0c92fef, enum_audio_devices() (58-84):
ids=malloc(size);
count=size / sizeof(AudioDeviceID);
stat=AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &size, ids);
if (success(stat, "get data")) {
for (UInt32i=0; i<count; i++) {
if (!obs_enum_audio_monitoring_device(cb, data, ids[i], allow_inputs))
Class
Unchecked allocation: NULL dereference when malloc fails.
How it is reached
Every walk of the CoreAudio device list on macOS goes through it: obs_enum_audio_monitoring_devices() (the monitoring device list in Settings → Audio), devices_match() and get_desktop_default_id(). When malloc(size) returns NULL, the NULL is handed to AudioObjectGetPropertyData() as the output buffer for size bytes, and if that call reports success the loop reads ids[i] from NULL. Only an allocation failure triggers it. No upstream issue.
Proposed fix and failing test
Return when ids is NULL, before the property read: the caller sees an empty device list, as it does when the size query fails.
RED: a cmocka test, test_coreaudio_enum_alloc, that compiles coreaudio-enum-devices.c.h over stand-ins for the CoreAudio calls and a malloc that can be made to fail (no Apple headers, so it builds on Linux). With the allocation failing, obs_enum_audio_monitoring_devices() must not read the device list into NULL and must not call the callback. A second case with a working allocator pins the normal walk (every output device reported, in order, stopping at the first false). GREEN: the NULL check.
RED: test_coreaudio_enum_alloc, a cmocka test that compiles coreaudio-enum-devices.c.h over CoreAudio stand-ins and a failing malloc (builds on Linux, no Apple headers). With the allocation failing, the device list isn't read into NULL and the callback isn't called; with it working, the normal walk is pinned.
GREEN: return from enum_audio_devices() when ids is NULL, before the property read.
Fixed by #2863 (merged as 32c4bcc): enum_audio_devices() in libobs/audio-monitoring/osx/coreaudio-enum-devices.c.h now returns an empty device list when its allocation fails, instead of asking CoreAudio to write the device ids into NULL. The new test_coreaudio_enum_alloc (7 cases, run in the Linux Tier 2 lane) failed 3 of 7 before the fix and passes now.
What is left: the new test has only been built on Linux, with CoreAudio stand-ins, so no native macOS or Windows Tier 2 run has built it. The macOS Tier 2 lane on master pushes covers that, and the file's port is covered by its own port issue.
Follow-up issue: none. Nothing in the code is left to fix.
Activity
rdoupe commentedon Oct 29, 2026
Claiming: #2862.
test_coreaudio_enum_alloc, a cmocka test that compilescoreaudio-enum-devices.c.hover CoreAudio stand-ins and a failingmalloc(builds on Linux, no Apple headers). With the allocation failing, the device list isn't read into NULL and the callback isn't called; with it working, the normal walk is pinned.enum_audio_devices()whenidsis NULL, before the property read.Draft PR with the RED commit within the hour.
test: Fail the CoreAudio device list allocation
libobs: Check the CoreAudio device list allocation
docs: Add the CoreAudio list fix to features
test: Fail the CoreAudio device list allocation
libobs: Check the CoreAudio device list allocation
docs: Add the CoreAudio list fix to features
test: Fail the CoreAudio device list allocation
libobs: Check the CoreAudio device list allocation
docs: Add the CoreAudio list fix to features
rdoupe commentedon Oct 29, 2026
Fixed by #2863 (merged as 32c4bcc):
enum_audio_devices()inlibobs/audio-monitoring/osx/coreaudio-enum-devices.c.hnow returns an empty device list when its allocation fails, instead of asking CoreAudio to write the device ids into NULL. The newtest_coreaudio_enum_alloc(7 cases, run in the Linux Tier 2 lane) failed 3 of 7 before the fix and passes now.What is left: the new test has only been built on Linux, with CoreAudio stand-ins, so no native macOS or Windows Tier 2 run has built it. The macOS Tier 2 lane on master pushes covers that, and the file's port is covered by its own port issue.
Follow-up issue: none. Nothing in the code is left to fix.
libobs: Check the CoreAudio device list allocation (obs-rust#2863)