Skip to content

Commit b81bc33

Browse files
Fix engine crash in SV_SetClient_Ping by ensuring gentity_t::client is never null
- In AllocateClientArray, link g_entities[i+1].client to game.clients[i] immediately. - In FreeClientArray, link g_entities[i+1].client to a static dummy client instead of nullptr. - This prevents race conditions during map restarts/shutdowns where the engine might access client structures after they are freed but before the entity array is reset.
1 parent b8818e3 commit b81bc33

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/server/gameplay/g_clients.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ namespace {
4040
if (gi.TagFree)
4141
gi.TagFree(ptr);
4242
}
43+
44+
gclient_t dummy_client;
4345
}
4446

4547
void AllocateClientArray(int maxClients) {
@@ -78,7 +80,7 @@ void FreeClientArray() {
7880
// [KEX]: Unlink client pointers
7981
if (g_entities && game.clients) {
8082
for (int i = 0; i < game.maxClients; i++) {
81-
g_entities[i + 1].client = nullptr;
83+
g_entities[i + 1].client = &dummy_client;
8284
}
8385
}
8486

0 commit comments

Comments
 (0)