# HG changeset patch # User Chris Cannam # Date 1426071802 0 # Node ID e603b44510c38da3246ffa936b76c97db92c9445 # Parent cafd65fc411bb13953bec4c611d771a5ed678677 Fix buffer overwrite in normalised case diff -r cafd65fc411b -r e603b44510c3 data/fileio/CodedAudioFileReader.cpp --- a/data/fileio/CodedAudioFileReader.cpp Wed Mar 11 09:29:44 2015 +0000 +++ b/data/fileio/CodedAudioFileReader.cpp Wed Mar 11 11:03:22 2015 +0000 @@ -439,19 +439,20 @@ sv_frame_t i = 0; sv_frame_t n = count * m_channelCount; + frames.resize(n); + m_dataLock.lockForRead(); while (i < n && in_range_for(m_data, idx)) { - frames.push_back(m_data[idx++]); - ++i; + frames[i++] = m_data[idx++]; } m_dataLock.unlock(); + + frames.resize(i); } } if (m_normalised) { - for (sv_frame_t i = 0; i < (sv_frame_t)(count * m_channelCount); ++i) { - frames[i] *= m_gain; - } + for (auto &f: frames) f *= m_gain; } return frames;