From 7cfae6b6360eefe8d9f6a1994a46f9dc731c39e4 Mon Sep 17 00:00:00 2001 From: dannyxjsuu Date: Wed, 22 Oct 2025 13:26:36 -0300 Subject: [PATCH] [HL2MP] Fix nullptr crash with `hl2mp_allow_pickup` on useable items Holding an item (like a health pack) and using it (e.g. healing) will free the object from memory, but player will still be holding it, pressing attack1 then would crash the game. Fix: - Check if pPhys still exists, if not, stop holding. --- src/game/shared/hl2mp/weapon_physcannon.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/game/shared/hl2mp/weapon_physcannon.cpp b/src/game/shared/hl2mp/weapon_physcannon.cpp index 26fdfefdb1a..638bf2f07cd 100644 --- a/src/game/shared/hl2mp/weapon_physcannon.cpp +++ b/src/game/shared/hl2mp/weapon_physcannon.cpp @@ -798,6 +798,13 @@ void CPlayerPickupController::Use( CBaseEntity *pActivator, CBaseEntity *pCaller return; } + // Stop holding when object doesn't exist anymore + if (!pPhys) + { + Shutdown(); + return; + } + #if STRESS_TEST vphysics_objectstress_t stress; CalculateObjectStress( pPhys, pAttached, &stress );