Mercurial > hg > vamp-tempogram
changeset 34:2b2e707c8c20
Test and error message for buffer overrun (in anticipation of actually fixing it!)
author | Chris Cannam |
---|---|
date | Thu, 04 Sep 2014 10:40:51 +0100 |
parents | a824d7d14eb9 |
children | 4010960c659e |
files | TempogramPlugin.cpp |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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()));