Skip to content

Fix AudioBufferList heap overflow with Studio Display microphone#2

Merged
idanyekutiel merged 1 commit intomainfrom
idanyekutiel/studio-display-mic-crash
Mar 13, 2026
Merged

Fix AudioBufferList heap overflow with Studio Display microphone#2
idanyekutiel merged 1 commit intomainfrom
idanyekutiel/studio-display-mic-crash

Conversation

@idanyekutiel
Copy link
Copy Markdown
Owner

Summary

Fixes crash on app launch/startup when Apple Studio Display is connected. The bug was in device enumeration code that didn't properly handle multi-buffer audio devices.

Root Cause

AudioBufferList is a variable-length C struct where the mBuffers array can contain multiple AudioBuffer entries. The old code allocated fixed-size storage (MemoryLayout<AudioBufferList>.size) which only fits one entry. Devices with multiple stream buffers (like the Studio Display's 3-microphone array) overflow this allocation, causing heap corruption and crash.

Fix

Allocate based on actual streamSize reported by CoreAudio instead of using fixed-size storage. This matches the pattern used by openal-soft and other audio libraries handling variable-length CoreAudio structures.

Testing

  • Crash occurred on app launch with Studio Display connected
  • Fix allows device enumeration to handle multi-buffer devices safely

…e Studio Display

AudioBufferList is a variable-length struct (mBuffers array is variable-size). The old code allocated fixed-size storage (MemoryLayout<AudioBufferList>.size) which only fits one AudioBuffer entry. Devices with multiple stream buffers (e.g. Studio Display's 3-mic array) overflow this allocation.

Now allocates based on actual streamSize reported by CoreAudio, matching the pattern used by openal-soft and other audio libraries. Fixes crash on app launch/device enumeration when Studio Display is connected.
@idanyekutiel idanyekutiel merged commit 7d86add into main Mar 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant