From 2dc28bb742f018e64c437d5fa41e3ff7c3c34fb3 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 18 Jan 2025 23:19:28 +0100 Subject: [PATCH] Common: fix crash when GetMaterialAtCrossHair() returns NULL We checked on the wrong far, materialGlue->Get() returns the static instance within the class, and since its always offset with 16 bytes, the address would be 0x10 if materialGlue is nullptr so the check would always be satisfied. Check on materialGlue itself now and only get the static instance if its available. --- src/common/callback.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/callback.cpp b/src/common/callback.cpp index e09b14f3..213dc015 100644 --- a/src/common/callback.cpp +++ b/src/common/callback.cpp @@ -305,10 +305,11 @@ static void PrintChildMat(const CMaterialGlue* const materialGlue, const char* c void Mat_CrossHair_f(const CCommand& args) { const CMaterialGlue* const materialGlue = v_GetMaterialAtCrossHair(); - const MaterialGlue_s* const material = materialGlue->Get(); - if (material) + if (materialGlue) { + const MaterialGlue_s* const material = materialGlue->Get(); + Msg(eDLL_T::MS, "______________________________________________________________\n"); Msg(eDLL_T::MS, "-+ Material --------------------------------------------------\n"); Msg(eDLL_T::MS, " |-- Address: '%llX'\n", material);