# HG changeset patch # User Chris Cannam # Date 1409823651 -3600 # Node ID 2b2e707c8c20977f9b1b9d72a5bce0cfdde7c91f # Parent a824d7d14eb96ce69cfcfba88b2bdbddd45b20a5 Test and error message for buffer overrun (in anticipation of actually fixing it!) diff -r a824d7d14eb9 -r 2b2e707c8c20 TempogramPlugin.cpp --- a/TempogramPlugin.cpp Thu Sep 04 10:40:31 2014 +0100 +++ b/TempogramPlugin.cpp Thu Sep 04 10:40:51 2014 +0100 @@ -526,7 +526,18 @@ float sum = 0; for (int j = 0; j < m_cyclicTempogramNumberOfOctaves; j++){ - sum += tempogramDFT[block][logBins[j][i]]; + + if (block >= tempogramDFT.size()) { + cerr << "ERROR: at block = " << block << ", i = " << i << ", j = " << j << ": block " << block << " >= tempogramDFT.size() " << tempogramDFT.size() << endl; + } else if (j > logBins.size()) { + cerr << "ERROR: at block = " << block << ", i = " << i << ", j = " << j << ": j " << j << " >= logBins.size() " << logBins.size() << endl; + } else if (i > logBins[j].size()) { + cerr << "ERROR: at block = " << block << ", i = " << i << ", j = " << j << ": i " << i << " >= logBins[j].size() " << logBins[j].size() << endl; + } else if (logBins[j][i] >= tempogramDFT[block].size()) { + cerr << "ERROR: at block = " << block << ", i = " << i << ", j = " << j << ": logBins[j][i] " << logBins[j][i] << " >= tempogramDFT[block].size() " << tempogramDFT[block].size() << endl; + } else { + sum += tempogramDFT[block][logBins[j][i]]; + } } cyclicTempogramFeature.values.push_back(sum/m_cyclicTempogramNumberOfOctaves); assert(!isnan(cyclicTempogramFeature.values.back()));