Fix CY0 buffer overflow in beamformer working struct #91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Identified and fixed a buffer overflow in the
CY0scratch buffer.The buffer was declared using the half-spectrum constant (
NFFTD2), but the synthesis logic treats it as full-spectrum (NFFT). This resulted in writing 126 floats (504 bytes) past the end of the array during the IFFT and spectrum extension stages.On the current ARM build, this overflow was overwriting the adjacent
XYstruct member. It did not trigger a crash solely due to the specific memory layout and the fact thatXYwas effectively unused at that point in the frame. This fix updatesCY0to the correct full-spectrum size to prevent the out-of-bounds writes.The Bug
The
CY0buffer was declared withNFFTD2(half-spectrum size), likely because it's used for some half-spectrum math early in the function.However, later in the synthesis stage (specifically the complex IFFT), we treat
CY0as a full-spectrum buffer. We end up writing about 126 floats past the end of the array.The Fix
I just bumped the size of
CY0to match the other full-spectrum buffers (mic,BM, etc).