Skip to content

Commit

Permalink
Fix 2 memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Bara committed Jul 20, 2019
1 parent a774c26 commit 868d4d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
10 changes: 6 additions & 4 deletions addons/sourcemod/scripting/ttt/ttt.sp
Expand Up @@ -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);

Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/ttt/ttt_hurtshot.sp
Expand Up @@ -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))
{
Expand Down
12 changes: 2 additions & 10 deletions addons/sourcemod/scripting/ttt/ttt_revive.sp
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -364,7 +357,6 @@ public Action Timer_Revive(Handle timer, DataPack pack)
}

g_hTimer[client] = null;
delete pack;
return Plugin_Stop;
}

Expand Down

0 comments on commit 868d4d9

Please sign in to comment.