[ModelSurfs] Fix possible memory leak

This commit is contained in:
momo5502 2016-12-19 18:14:15 +01:00
parent 2b226dbcdb
commit d8d67898f3

View File

@ -109,6 +109,19 @@ namespace Components
Game::XSurface* tempSurfaces = allocator.allocateArray<Game::XSurface>(modelSurfs->numSurfaces);
char* surfaceData = reinterpret_cast<char*>(modelSurfs->surfaces);
if (ModelSurfs::AllocMap.find(modelSurfs->name) != ModelSurfs::AllocMap.end())
{
Game::CModelAllocData* allocData = ModelSurfs::AllocMap[modelSurfs->name];
if (allocData)
{
Utils::Memory::FreeAlign(allocData->indexBuffer);
Utils::Memory::FreeAlign(allocData->vertexBuffer);
Utils::Memory::Free(allocData->mainArray);
Utils::Memory::Free(allocData);
}
}
ModelSurfs::AllocMap[modelSurfs->name] = allocationData;
*reinterpret_cast<void**>(reinterpret_cast<char*>(allocationData->mainArray) + 44) = allocationData;