From 32c0dc773e509d48009fd960d843b2cae7eb7ac8 Mon Sep 17 00:00:00 2001 From: Itms Date: Sat, 8 Apr 2017 15:58:10 +0000 Subject: [PATCH] Fix memory leak in CCmpPathfinder, patch by Sandarac. The terrain grid can be renewed without proper deallocation, which happens at least at the start of a game when MT_TerrainChanged is sent. Reviewers: wraitii, Itms Differential Revision: https://code.wildfiregames.com/D247 This was SVN commit r19388. --- source/simulation2/components/CCmpPathfinder.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/simulation2/components/CCmpPathfinder.cpp b/source/simulation2/components/CCmpPathfinder.cpp index c1f2923825..eea299b971 100644 --- a/source/simulation2/components/CCmpPathfinder.cpp +++ b/source/simulation2/components/CCmpPathfinder.cpp @@ -470,6 +470,7 @@ void CCmpPathfinder::UpdateGrid() { m_MapSize = terrainSize; m_Grid = new Grid(m_MapSize * Pathfinding::NAVCELLS_PER_TILE, m_MapSize * Pathfinding::NAVCELLS_PER_TILE); + SAFE_DELETE(m_TerrainOnlyGrid); m_TerrainOnlyGrid = new Grid(m_MapSize * Pathfinding::NAVCELLS_PER_TILE, m_MapSize * Pathfinding::NAVCELLS_PER_TILE); m_ObstructionsDirty = { true, true, true, Grid(m_MapSize * Pathfinding::NAVCELLS_PER_TILE, m_MapSize * Pathfinding::NAVCELLS_PER_TILE) };