Skip to content

Commit 405e840

Browse files
authored
fix(coreaudio): UB and silent failure in loopback device creation (#1123)
1 parent 70079bb commit 405e840

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4343
- **ALSA**: Fix rare panics when dropping the stream is interrupted.
4444
- **ASIO**: Fix enumeration returning only the first device when using `collect`.
4545
- **ASIO**: Fix device enumeration and stream creation failing when called from spawned threads.
46+
- **CoreAudio**: Fix undefined behaviour and silent failure in loopback device creation.
4647
- **Emscripten**: Fix build failure introduced by newer `wasm-bindgen` versions.
4748

4849
## [0.17.3] - 2026-02-18

src/host/coreaudio/macos/loopback.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,20 @@ impl LoopbackDevice {
103103

104104
let mut tap_obj_id: MaybeUninit<AudioObjectID> = MaybeUninit::uninit();
105105
let tap_obj_id = unsafe {
106-
AudioHardwareCreateProcessTap(Some(tap_desc.as_ref()), tap_obj_id.as_mut_ptr());
106+
let status =
107+
AudioHardwareCreateProcessTap(Some(tap_desc.as_ref()), tap_obj_id.as_mut_ptr());
108+
check_os_status(status)?;
107109
tap_obj_id.assume_init()
108110
};
109111
let tap_uid = unsafe { tap_desc.UUID().UUIDString() };
110112

111113
// 2 - Create aggregate device
112114
let aggregate_device_properties = create_audio_aggregate_device_properties(tap_uid);
113-
let aggregate_device_id: AudioObjectID = 0;
115+
let mut aggregate_device_id: AudioObjectID = 0;
114116
let status = unsafe {
115117
AudioHardwareCreateAggregateDevice(
116118
aggregate_device_properties.as_ref(),
117-
NonNull::from(&aggregate_device_id),
119+
NonNull::from(&mut aggregate_device_id),
118120
)
119121
};
120122
check_os_status(status)?;

0 commit comments

Comments
 (0)