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.
This commit is contained in:
Kawe Mazidjatari 2025-01-18 23:19:28 +01:00
parent 2083bc73fa
commit 2dc28bb742

View File

@ -305,10 +305,11 @@ static void PrintChildMat(const CMaterialGlue* const materialGlue, const char* c
void Mat_CrossHair_f(const CCommand& args) void Mat_CrossHair_f(const CCommand& args)
{ {
const CMaterialGlue* const materialGlue = v_GetMaterialAtCrossHair(); 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, "______________________________________________________________\n");
Msg(eDLL_T::MS, "-+ Material --------------------------------------------------\n"); Msg(eDLL_T::MS, "-+ Material --------------------------------------------------\n");
Msg(eDLL_T::MS, " |-- Address: '%llX'\n", material); Msg(eDLL_T::MS, " |-- Address: '%llX'\n", material);