From 25adddaf46fb109724a35d0e16b6a8b02ede0eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kerim=20=C4=8Camd=C5=BEi=C4=87?= Date: Wed, 5 Feb 2025 22:05:52 +0100 Subject: [PATCH] Fixed color_correction_volume crash caused by dangling pointers inside of ccmngr --- sp/src/game/client/colorcorrectionmgr.cpp | 16 ++++++++++++++++ sp/src/game/client/colorcorrectionmgr.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/sp/src/game/client/colorcorrectionmgr.cpp b/sp/src/game/client/colorcorrectionmgr.cpp index cf1210ac..f04438d6 100644 --- a/sp/src/game/client/colorcorrectionmgr.cpp +++ b/sp/src/game/client/colorcorrectionmgr.cpp @@ -157,6 +157,22 @@ void CColorCorrectionMgr::CommitColorCorrectionWeights() } m_colorCorrectionWeights.RemoveAll(); } + +void CColorCorrectionMgr::LevelShutdownPreEntity() +{ + //Clean up the vectors when shuting down a level + //will keep dangling pointers inside of the vector causing a nullptr crash + if (g_ColorCorrectionVolumeList.Base()) + { + g_ColorCorrectionVolumeList.Purge(); + } + + if (g_ColorCorrectionList.Base()) + { + g_ColorCorrectionList.Purge(); + } +} + #else void CColorCorrectionMgr::SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight ) { diff --git a/sp/src/game/client/colorcorrectionmgr.h b/sp/src/game/client/colorcorrectionmgr.h index 3eba0f8c..8492ac20 100644 --- a/sp/src/game/client/colorcorrectionmgr.h +++ b/sp/src/game/client/colorcorrectionmgr.h @@ -76,6 +76,8 @@ private: CUtlVector< SetWeightParams_t > m_colorCorrectionWeights; void CommitColorCorrectionWeights(); + + void LevelShutdownPreEntity(); #endif };