Skip to content

Commit 66290a8

Browse files
committed
Fix null-pointer access crash
1 parent b1e88dd commit 66290a8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Client/mods/deathmatch/ClientCommands.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ bool COMMAND_Executed(const char* szCommand, const char* szArguments, bool bHand
6060
g_pClientGame->GetRegisteredCommands()->ProcessCommand(szCommandBufferPointer, szArguments);
6161

6262
// Call the onClientConsole event
63-
auto pLocalPlayer = g_pClientGame->GetLocalPlayer();
63+
CClientPlayer* localPlayer = g_pClientGame->GetLocalPlayer();
6464

65-
if (pLocalPlayer)
65+
if (localPlayer != nullptr)
6666
{
6767
CLuaArguments Arguments;
6868

@@ -76,7 +76,7 @@ bool COMMAND_Executed(const char* szCommand, const char* szArguments, bool bHand
7676
Arguments.PushString(strClumpedCommand);
7777
}
7878

79-
pLocalPlayer->CallEvent("onClientConsole", Arguments, true);
79+
localPlayer->CallEvent("onClientConsole", Arguments, true);
8080
}
8181

8282
// Write the chatlength and the content
@@ -95,12 +95,16 @@ bool COMMAND_Executed(const char* szCommand, const char* szArguments, bool bHand
9595
}
9696
else
9797
{
98-
// Call the onClientCoreCommand event
99-
CLuaArguments Arguments;
100-
Arguments.PushString(szCommand);
98+
CClientPlayer* localPlayer = g_pClientGame->GetLocalPlayer();
10199

102-
auto pLocalPlayer = g_pClientGame->GetLocalPlayer();
103-
pLocalPlayer->CallEvent("onClientCoreCommand", Arguments, true);
100+
if (localPlayer != nullptr)
101+
{
102+
// Call the onClientCoreCommand event
103+
CLuaArguments Arguments;
104+
Arguments.PushString(szCommand);
105+
106+
localPlayer->CallEvent("onClientCoreCommand", Arguments, true);
107+
}
104108

105109
// Call our comand-handlers for core-executed commands too, if allowed
106110
if (bAllowScriptedBind)

0 commit comments

Comments
 (0)