[Stk] Bug in RtWvOut (4.3.0)

Carlos Pita carlosjosepita at gmail.com
Sat Jul 26 14:09:04 PDT 2008


Hi all,

I've found a bug in version 4.3.0, specifically in class RtWvOut.
Maybe this is corrected in 4.3.1, as the release notes say something
about a fix in RtWvOut, but I didn't have the time to check if it is
so.

The problem is around lines:

data_.resize( size * nBuffers, nChannels );
unsigned int offset = (unsigned int ) (data_.frames() / 2.0); <----- here
writeIndex_ = offset;    // start writing half-way into buffer

If the WvOut unit has more than one channel the writeIndex should be
data_.frames() / (2.0 * nChannels), because later it's used to produce
an index into the data array multiplying it by nChannels.

Say nChannels = 2, then data will be read starting from
(data_.frames() / 2.0) * 2, which is beyond the data array limits.
This leads to memory corruption. These wrong memory accesses are
carried out here:

   index = writeIndex_ * nChannels;
   for ( j=0; j<nChannels; j++ ) {
        data_[index] = frames[iFrame];
        clipTest( data_[index++] );
        iFrame += hop;
      }

HIH

Regards
-Carlos



More information about the Stk mailing list