The code where the leak originates is the following:
Code: Select all
void OgreResourceProvider::loadInputSourceContainer(const String& filename, InputSourceContainer& output)
{
Ogre::DataChunk input;
if( !Ogre::ArchiveManager::getSingleton()._findResourceData(
filename.c_str(), input ) )
{
throw InvalidRequestException((utf8*)
"Scheme::Scheme - Filename supplied for Scheme loading must be valid");
}
XERCES_CPP_NAMESPACE_USE
InputSource* mInputSource = new MemBufInputSource(input.getPtr(), input.getSize(), filename.c_str(), false);
output.setData(mInputSource);
}
When MemBufInputSource is created, false is passed for adoptBuffer. Passing false for adoptBuffer means that when the instance of MemBufInputSource is deleted, it will not delete the buffer passed in the constructor ie input.getPtr(). When "output" is destroyed later on, it only deletes the instance of MemBufInputSource ie the pointer to the instance passed using output.setData(mInputSource) and not the memory that was allocated in Ogre::DataChunk::allocate (line 55: new uchar[mSize + 1];).
I did find a solution but I think either CE or _Mental_ should verify this before I put my foot in my mouth by posting the solution I came up with.