From 868d4d9f7a86ef65ec719ddca72828ec6101513c Mon Sep 17 00:00:00 2001 From: Bara Date: Sat, 20 Jul 2019 15:17:41 +0200 Subject: [PATCH] Fix 2 memory leaks --- addons/sourcemod/scripting/ttt/ttt.sp | 10 ++++++---- addons/sourcemod/scripting/ttt/ttt_hurtshot.sp | 1 + addons/sourcemod/scripting/ttt/ttt_revive.sp | 12 ++---------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/addons/sourcemod/scripting/ttt/ttt.sp b/addons/sourcemod/scripting/ttt/ttt.sp index daca96c9..10f0b06c 100644 --- a/addons/sourcemod/scripting/ttt/ttt.sp +++ b/addons/sourcemod/scripting/ttt/ttt.sp @@ -2828,6 +2828,8 @@ public void Frame_RechangeName(DataPack pack) char sName[MAX_NAME_LENGTH]; pack.ReadString(sName, sizeof(sName)); + + delete pack; int client = GetClientOfUserId(userid); @@ -3458,9 +3460,9 @@ public int TTT_OnButtonPress(int client, int button) if (!g_cSilentIdEnabled.BoolValue || !(bInWalk && TTT_IsValidRole(client, g_cSilentIdRoles.IntValue))) { - char sBuffer[32]; - Format(sBuffer, sizeof(sBuffer), "Found %s", sVictimRole); - + char sBuffer[32]; + Format(sBuffer, sizeof(sBuffer), "Found %s", sVictimRole); + LoopValidClients(j) { CPrintToChat(j, "%s %T", g_sTag, sBuffer, j, client, iRagdollC[VictimName]); @@ -3489,7 +3491,7 @@ public int TTT_OnButtonPress(int client, int button) if (bSetColor) { - if (iRagdollC[VictimTeam] == TTT_TEAM_INNOCENT) + if (iRagdollC[VictimTeam] == TTT_TEAM_INNOCENT) { SetEntityRenderColor(iEntity, 0, 255, 0, 255); } diff --git a/addons/sourcemod/scripting/ttt/ttt_hurtshot.sp b/addons/sourcemod/scripting/ttt/ttt_hurtshot.sp index cf454984..c11f7098 100644 --- a/addons/sourcemod/scripting/ttt/ttt_hurtshot.sp +++ b/addons/sourcemod/scripting/ttt/ttt_hurtshot.sp @@ -252,6 +252,7 @@ public void Frame_DropEntity(DataPack pack) pack.Reset(); int client = GetClientOfUserId(pack.ReadCell()); int iEntity = EntRefToEntIndex(pack.ReadCell()); + delete pack; if (TTT_IsClientValid(client) && IsValidEntity(iEntity)) { diff --git a/addons/sourcemod/scripting/ttt/ttt_revive.sp b/addons/sourcemod/scripting/ttt/ttt_revive.sp index 8bec2a20..ef1d64d8 100644 --- a/addons/sourcemod/scripting/ttt/ttt_revive.sp +++ b/addons/sourcemod/scripting/ttt/ttt_revive.sp @@ -281,46 +281,42 @@ public Action Timer_Revive(Handle timer, DataPack pack) int client = GetClientOfUserId(pack.ReadCell()); int entity = EntRefToEntIndex(pack.ReadCell()); + + delete pack; if (!TTT_IsClientValid(client) || !g_bHasRevive[client]) { g_hTimer[client] = null; - delete pack; return Plugin_Stop; } if (g_hTimer[client] == null) { g_hTimer[client] = null; - delete pack; return Plugin_Stop; } if (g_iEndTime[client] == -1 || g_iStartTime[client] == -1 || g_iCountdown[client] == -1) { g_hTimer[client] = null; - delete pack; return Plugin_Stop; } if (!IsValidEntity(entity)) { g_hTimer[client] = null; - delete pack; return Plugin_Stop; } if (!g_bInUse[client]) { g_hTimer[client] = null; - delete pack; return Plugin_Stop; } if (g_iRagdoll[client] == TTT_GetGrabEntity(client)) { g_hTimer[client] = null; - delete pack; return Plugin_Stop; } @@ -329,21 +325,18 @@ public Action Timer_Revive(Handle timer, DataPack pack) if (!TTT_IsClientValid(target)) { g_hTimer[client] = null; - delete pack; return Plugin_Stop; } if (TTT_GetClientRole(target) != TTT_TEAM_TRAITOR && TTT_GetClientRole(target) != TTT_TEAM_DETECTIVE) { g_hTimer[client] = null; - delete pack; return Plugin_Stop; } if (TTT_GetClientRole(client) != TTT_GetClientRole(target)) { g_hTimer[client] = null; - delete pack; return Plugin_Stop; } @@ -364,7 +357,6 @@ public Action Timer_Revive(Handle timer, DataPack pack) } g_hTimer[client] = null; - delete pack; return Plugin_Stop; }