From 95636da6d99a428b0916238b9ba2e5457f54ceed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 21 Jul 2022 15:32:11 +0200 Subject: [PATCH] Fix out of bounds access with highlighted messages in server demos ``` src/game/client/components/chat.cpp:795:89: runtime error: index -1 out of bounds for type 'CClientData [64]' #0 0x55c133fd047a in CChat::AddLine(int, int, char const*) src/game/client/components/chat.cpp:795 #1 0x55c133fc80b5 in CChat::OnMessage(int, void*) src/game/client/components/chat.cpp:570 #2 0x55c134677688 in CGameClient::OnMessage(int, CUnpacker*, int, bool) src/game/client/gameclient.cpp:770 #3 0x55c133c282d2 in CClient::OnDemoPlayerMessage(void*, int) src/engine/client/client.cpp:2627 #4 0x55c134ccdcba in CDemoPlayer::DoTick() src/engine/shared/demo.cpp:679 #5 0x55c134cdac81 in CDemoPlayer::Update(bool) src/engine/shared/demo.cpp:1007 #6 0x55c133c2a08b in CClient::Update() src/engine/client/client.cpp:2686 #7 0x55c133c4c9eb in CClient::Run() src/engine/client/client.cpp:3296 #8 0x55c133cbd64f in main src/engine/client/client.cpp:4761 ``` --- src/game/client/components/chat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index e74e2410098..a7d4ce0b48e 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -792,7 +792,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) { // on demo playback use local id from snap directly, // since m_aLocalIDs isn't valid there - if(LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName)) + if(m_pClient->m_Snap.m_LocalClientID >= 0 && LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName)) Highlighted = true; }