Skip to content

fix: clamp spectrum band bins against Nyquist to prevent out-of-bounds read#135

Open
mvanhorn wants to merge 1 commit into
vercel-labs:mainfrom
mvanhorn:fix/108-macos-spectrum-oob-nyquist
Open

fix: clamp spectrum band bins against Nyquist to prevent out-of-bounds read#135
mvanhorn wants to merge 1 commit into
vercel-labs:mainfrom
mvanhorn:fix/108-macos-spectrum-oob-nyquist

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

NativeSdkSpectrumComputeBands computed each band's low_bin from a log-spaced frequency and only clamped high_bin against the Nyquist limit. For the top bands, low_bin can exceed FFT_SIZE/2 - 1, so the inner accumulation loop read past the end of the magnitude buffer. This clamps low_bin against the same max_bin and skips (writes 0 for) any band whose range starts beyond Nyquist.

Closes #108

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

macOS: OOB panic in NativeSdkSpectrumComputeBands when sample rate < 32 kHz (index past Nyquist)

1 participant