Mercurial > hg > svcore
changeset 1198:b494439a301c spectrogram-minor-refactor
Avoid overrun-by-1
author | Chris Cannam |
---|---|
date | Wed, 03 Aug 2016 14:19:56 +0100 |
parents | fbe0fd84cb50 |
children | 4d0d94ba2ea7 |
files | base/ColumnOp.h |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/base/ColumnOp.h Mon Aug 01 16:25:06 2016 +0100 +++ b/base/ColumnOp.h Wed Aug 03 14:19:56 2016 +0100 @@ -155,7 +155,7 @@ const std::vector<double> &binfory, int minbin, bool interpolate) { - + std::vector<float> out(h, 0.f); int bins = int(in.size()); @@ -194,7 +194,8 @@ int by0 = int(sy0 + 0.0001); int by1 = int(sy1 + 0.0001); if (by1 < by0 + 1) by1 = by0 + 1; - + if (by1 >= bins) by1 = by1 - 1; + for (int bin = by0; bin < by1; ++bin) { float value = in[bin];