Here is one issue:
void WaveTableManager::insert(WaveTable * WT,int position)
{
if (wtvector.size()<=position)
wtvector.resize(position);
wtvector[position]=WT; // < -- Out of bounds access
}
When you call resize()
, the upper bound is vector::size()-1
. Since position
is the new size of the vector, what you probably want is this:
wtvector[position - 1] = WT;
5
solved can not understand this SEGFAULT [closed]