Beyond Stack Read (BSR) error

yfei

30-12-2010 19:32:50

Rational Purify detected Beyond Stack Read (BSR) error in method Buffer WavSound::bufferData(Ogre::DataStreamPtr dataStream, int size) { .. }

inside the method, std::vector<char> data; is defined, and used as return value.

should declare it as static. and clear it.

my fix is like:

// original
Buffer WavSound::bufferData(Ogre::DataStreamPtr dataStream, int size)
{
size_t bytes;
std::vector<char> data;
...

// fix
Buffer WavSound::bufferData(Ogre::DataStreamPtr dataStream, int size)
{
size_t bytes;
static std::vector<char> data;
data.clear();
...

Phobius

08-01-2011 02:03:26

Buffer is returned by value, therefore this is ok. Your fix would only make sense if a reference was being returned, but this is not the case.