From d5e4e89ba54657f570b15a351667e21d4f886f4e Mon Sep 17 00:00:00 2001 From: Greyscale Date: Thu, 23 Jul 2009 17:05:04 -0700 Subject: [PATCH] Fixed various memory leaks. --- src/zr/infect.inc | 4 ++++ src/zr/models.inc | 4 ++++ src/zr/playerclasses/playerclasses.inc | 5 +++++ src/zr/roundend.inc | 3 +++ src/zr/sayhooks.inc | 8 ++++++++ 5 files changed, 24 insertions(+) diff --git a/src/zr/infect.inc b/src/zr/infect.inc index 627e21e..17e47cf 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -197,6 +197,8 @@ InfectOnClientDisconnect(client) // If there are no eligible client's then stop. if (!eligibleclients) { + // Destroy handle. + CloseHandle(arrayEligibleClients); return; } @@ -416,6 +418,8 @@ public Action:InfectMotherZombie(Handle:timer) // If there are no eligible client's then stop. if (!eligibleclients) { + // Destroy handle. + CloseHandle(arrayEligibleClients); return; } diff --git a/src/zr/models.inc b/src/zr/models.inc index 1386157..359f3eb 100644 --- a/src/zr/models.inc +++ b/src/zr/models.inc @@ -302,6 +302,10 @@ stock ModelsGetRandomModelIndex(String:modelpath[], maxlen, bool:all = true, boo if (size == 0) { strcopy(modelpath, maxlen, ""); + + // Destroy the handle. + CloseHandle(modelsarray); + return; } diff --git a/src/zr/playerclasses/playerclasses.inc b/src/zr/playerclasses/playerclasses.inc index a2d8c5c..aa156e5 100644 --- a/src/zr/playerclasses/playerclasses.inc +++ b/src/zr/playerclasses/playerclasses.inc @@ -409,6 +409,11 @@ ClassLoad(bool:keepMultipliers = false) if (!exists) { LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Playerclasses, "Config Validation", "Missing playerclasses config file \"%s\"", pathclasses); + + // Remove key/value cache. + CloseHandle(kvClassData); + kvClassData = INVALID_HANDLE; + return; } diff --git a/src/zr/roundend.inc b/src/zr/roundend.inc index 081fe39..7fc0d0d 100644 --- a/src/zr/roundend.inc +++ b/src/zr/roundend.inc @@ -340,6 +340,9 @@ RoundEndBalanceTeams() // If there are no eligible client's then stop. if (!eligibleclients) { + // Destroy handle. + CloseHandle(arrayEligibleClients); + return; } diff --git a/src/zr/sayhooks.inc b/src/zr/sayhooks.inc index 2302c0e..2274f58 100644 --- a/src/zr/sayhooks.inc +++ b/src/zr/sayhooks.inc @@ -78,6 +78,10 @@ SayHooksGetPublicChatTrigger(String:trigger[], maxlen) if (!success) { strcopy(trigger, maxlen, SAYHOOKS_CHAT_PUBLIC_DEFAULT); + + // Close the handle. + CloseHandle(kvCore); + return; } @@ -117,6 +121,10 @@ SayHooksGetSilentChatTrigger(String:trigger[], maxlen) if (!success) { strcopy(trigger, maxlen, SAYHOOKS_CHAT_SILENT_DEFAULT); + + // Close the handle. + CloseHandle(kvCore); + return; }