Browse Source

Filter: fixed out of bound access in ModeFilter

master_rangefinder
Andrew Tridgell 3 years ago
parent
commit
4ed55d9e21
  1. 2
      libraries/Filter/ModeFilter.cpp

2
libraries/Filter/ModeFilter.cpp

@ -85,7 +85,7 @@ void ModeFilter<T,FILTER_SIZE>::isort(T new_sample, bool drop_high) @@ -85,7 +85,7 @@ void ModeFilter<T,FILTER_SIZE>::isort(T new_sample, bool drop_high)
i = 0;
// if the element is lower than our new sample, push it down one position
while ( FilterWithBuffer<T,FILTER_SIZE>::samples[i+1] < new_sample && i < FilterWithBuffer<T,FILTER_SIZE>::sample_index-1 ) {
while ( i < FilterWithBuffer<T,FILTER_SIZE>::sample_index-1 && FilterWithBuffer<T,FILTER_SIZE>::samples[i+1] < new_sample ) {
FilterWithBuffer<T,FILTER_SIZE>::samples[i] = FilterWithBuffer<T,FILTER_SIZE>::samples[i+1];
i++;
}

Loading…
Cancel
Save