From 1f10bb164360d12379be98c58ea2e5ec21811aec Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 24 Nov 2022 13:41:18 +0100 Subject: [PATCH] Check ptr for 's_pLevelSetKV' before deleting Only delete if the pointer is valid to prevent segmentation fault. --- r5dev/engine/cmodel_bsp.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/r5dev/engine/cmodel_bsp.cpp b/r5dev/engine/cmodel_bsp.cpp index addde464..d3ea28e7 100644 --- a/r5dev/engine/cmodel_bsp.cpp +++ b/r5dev/engine/cmodel_bsp.cpp @@ -244,8 +244,12 @@ void Mod_ProcessPakQueue() g_pakLoadApi->UnloadPak(*(RPakHandle_t*)v10); Mod_UnloadPakFile(); // Unload mod pak files. - s_pLevelSetKV->DeleteThis(); // Delete current level settings if we drop all paks.. - s_pLevelSetKV = nullptr; + if (s_pLevelSetKV) + { + // Delete current level settings if we drop all paks.. + s_pLevelSetKV->DeleteThis(); + s_pLevelSetKV = nullptr; + } } if (v13 && (unsigned int)(v13 - 13) > 1) return;