Fix array overrun
This commit is contained in:
@@ -458,12 +458,17 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
double descendToValley(double f, const double *const magnitudes) const {
|
double descendToValley(double f, const double *const magnitudes) const {
|
||||||
|
if (f == 0.0 || f == m_parameters.sampleRate/2.0) {
|
||||||
|
// These are special cases
|
||||||
|
return f;
|
||||||
|
}
|
||||||
int b = binForFrequency(f, m_configuration.classificationFftSize,
|
int b = binForFrequency(f, m_configuration.classificationFftSize,
|
||||||
m_parameters.sampleRate);
|
m_parameters.sampleRate);
|
||||||
|
int n = m_configuration.classificationFftSize/2;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
if (magnitudes[b+1] < magnitudes[b]) {
|
if (b < n && magnitudes[b+1] < magnitudes[b]) {
|
||||||
++b;
|
++b;
|
||||||
} else if (magnitudes[b-1] < magnitudes[b]) {
|
} else if (b > 0 && magnitudes[b-1] < magnitudes[b]) {
|
||||||
--b;
|
--b;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user