From b4eee122ddd9e1e6cb3090b9f57e5bc48b1cdf5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 21 Jul 2022 15:28:31 +0200 Subject: [PATCH] Fix null pointer access in maplayers when the snapshot has no game info ``` src/game/client/components/maplayers.cpp:98:112: runtime error: member access within null pointer of type 'const struct CNetObj_GameInfo' #0 0x55d84eea9e1e in CMapLayers::EnvelopeEval(int, int, ColorRGBA&, void*) src/game/client/components/maplayers.cpp:98 #1 0x55d84f518082 in CRenderTools::ForceRenderQuads(CQuad*, int, int, void (*)(int, int, ColorRGBA&, void*), void*, float) src/game/client/render_map.cpp:112 #2 0x55d84f517ac7 in CRenderTools::RenderQuads(CQuad*, int, int, void (*)(int, int, ColorRGBA&, void*), void*) src/game/client/render_map.cpp:98 #3 0x55d84eee10b0 in CMapLayers::OnRender() src/game/client/components/maplayers.cpp:1839 #4 0x55d84f34b915 in CGameClient::OnRender() src/game/client/gameclient.cpp:640 #5 0x55d84e8d44c2 in CClient::Render() src/engine/client/client.cpp:1222 #6 0x55d84e92d1a0 in CClient::Run() src/engine/client/client.cpp:3370 #7 0x55d84e99964f in main src/engine/client/client.cpp:4761 ``` --- src/game/client/components/maplayers.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index e63f467be..6c21603af 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -94,15 +94,18 @@ void CMapLayers::EnvelopeEval(int TimeOffsetMillis, int Env, ColorRGBA &Channels } if(pItem->m_Version < 2 || pItem->m_Synchronized) { - // get the lerp of the current tick and prev - int MinTick = pThis->Client()->PrevGameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick; - int CurTick = pThis->Client()->GameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick; - s_Time = std::chrono::nanoseconds((int64_t)(mix( - 0, - (CurTick - MinTick), - (double)pThis->Client()->IntraGameTick(g_Config.m_ClDummy)) * - TickToNanoSeconds.count())) + - MinTick * TickToNanoSeconds; + if(pThis->m_pClient->m_Snap.m_pGameInfoObj) + { + // get the lerp of the current tick and prev + int MinTick = pThis->Client()->PrevGameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick; + int CurTick = pThis->Client()->GameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick; + s_Time = std::chrono::nanoseconds((int64_t)(mix( + 0, + (CurTick - MinTick), + (double)pThis->Client()->IntraGameTick(g_Config.m_ClDummy)) * + TickToNanoSeconds.count())) + + MinTick * TickToNanoSeconds; + } } else {