AP_HAL: ensure the DSP tracked peaks do not overflow the buffer

This commit is contained in:
Andy Piper 2023-01-19 20:43:27 +00:00 committed by Andrew Tridgell
parent 28d050a36b
commit 93ec74350c
1 changed files with 2 additions and 0 deletions

View File

@ -358,6 +358,8 @@ uint16_t DSP::fft_stop_average(FFTWindowState* fft, uint16_t start_bin, uint16_t
scratch_space, peaks, MAX_TRACKED_PEAKS, 0.0f, -1.0f, smoothwidth, 2);
hal.util->free_type(scratch_space, sizeof(float) * fft->_num_stored_freqs, DSP_MEM_REGION);
numpeaks = MIN(numpeaks, uint16_t(MAX_TRACKED_PEAKS));
// now try and find the lowest harmonic
for (uint16_t i = 0; i < numpeaks; i++) {
const uint16_t bin = peaks[i] + start_bin;