Add null checks to all free calls to prevent crash on server close. (#709)

This commit is contained in:
Jett 2022-08-04 14:54:14 +01:00 committed by GitHub
parent e6c7f744b5
commit 88f316bf93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 11 deletions

View File

@ -28,13 +28,13 @@ dNavMesh::dNavMesh(uint32_t zoneId) {
dNavMesh::~dNavMesh() {
// Clean up Recast information
rcFreeHeightField(m_Solid);
rcFreeCompactHeightfield(m_CHF);
rcFreeContourSet(m_CSet);
rcFreePolyMesh(m_PMesh);
rcFreePolyMeshDetail(m_PMDMesh);
dtFreeNavMesh(m_NavMesh);
dtFreeNavMeshQuery(m_NavQuery);
if(m_Solid) rcFreeHeightField(m_Solid);
if (m_CHF) rcFreeCompactHeightfield(m_CHF);
if (m_CSet) rcFreeContourSet(m_CSet);
if (m_PMesh) rcFreePolyMesh(m_PMesh);
if (m_PMDMesh) rcFreePolyMeshDetail(m_PMDMesh);
if (m_NavMesh) dtFreeNavMesh(m_NavMesh);
if (m_NavQuery) dtFreeNavMeshQuery(m_NavQuery);
if (m_Ctx) delete m_Ctx;
if (m_Triareas) delete[] m_Triareas;

View File

@ -32,9 +32,10 @@ dpWorld::~dpWorld() {
m_Grid = nullptr;
}
m_NavMesh->~dNavMesh();
if (m_NavMesh) {
delete m_NavMesh;
m_NavMesh = nullptr;
}
}
void dpWorld::StepWorld(float deltaTime) {

View File

@ -42,5 +42,5 @@ private:
std::vector<dpEntity*> m_StaticEntities;
std::vector<dpEntity*> m_DynamicEntites;
dNavMesh* m_NavMesh;
dNavMesh* m_NavMesh = nullptr;
};