From c9f80801e57644cdbeeca15593a1756ee5aa1c05 Mon Sep 17 00:00:00 2001 From: Sam V Date: Sun, 28 Nov 2021 22:06:41 +0100 Subject: [PATCH] FIx incorrect deletion of memory allocated with new[] #91 --- dlls/nodes.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index 3890af714..38c0f143c 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -3305,14 +3305,12 @@ void CGraph ::ComputeStaticRoutingTables() } ALERT(at_aiconsole, "Size of Routes = %d\n", nTotalCompressedSize); } - if (Routes) - delete Routes; - if (BestNextNodes) - delete BestNextNodes; - if (pRoute) - delete pRoute; - if (pMyPath) - delete pMyPath; + + delete[] Routes; + delete[] BestNextNodes; + delete[] pRoute; + delete[] pMyPath; + Routes = 0; BestNextNodes = 0; pRoute = 0; @@ -3447,10 +3445,8 @@ void CGraph ::TestRoutingTables() EnoughSaid: - if (pMyPath) - delete pMyPath; - if (pMyPath2) - delete pMyPath2; + delete[] pMyPath; + delete[] pMyPath2; pMyPath = 0; pMyPath2 = 0; }