From fd40a55b9fb62cf60c8fc57cf4647c85f51068a6 Mon Sep 17 00:00:00 2001 From: nullsystem <15316579+nullsystem@users.noreply.github.com> Date: Sun, 5 Apr 2026 18:27:06 +0100 Subject: [PATCH] Bots deinit - Guard against random nullptr deref on NEORules Rare random crash, disconnecting a local server and deinitalizing, a nullptr deref can happen in: `CNEOBotVision::IsIgnored` getting ghoster player from `NEORules()`. --- src/game/server/neo/bot/behavior/neo_bot_grenade_throw.cpp | 5 +++++ src/game/server/neo/bot/neo_bot_vision.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/game/server/neo/bot/behavior/neo_bot_grenade_throw.cpp b/src/game/server/neo/bot/behavior/neo_bot_grenade_throw.cpp index ce1f60ef0..5a3a80074 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_grenade_throw.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_grenade_throw.cpp @@ -343,6 +343,11 @@ ActionResult< CNEOBot > CNEOBotGrenadeThrow::Update( CNEOBot *me, float interval //--------------------------------------------------------------------------------------------- void CNEOBotGrenadeThrow::OnEnd( CNEOBot *me, Action< CNEOBot > *nextAction ) { + if (!NEORules()) // This can get called on de-init + { + return; + } + // Restore looking and weapon handling behaviors me->PopRequiredWeapon(); me->StartLookingAroundForEnemies(); diff --git a/src/game/server/neo/bot/neo_bot_vision.cpp b/src/game/server/neo/bot/neo_bot_vision.cpp index 75d240feb..61b2f7b8d 100644 --- a/src/game/server/neo/bot/neo_bot_vision.cpp +++ b/src/game/server/neo/bot/neo_bot_vision.cpp @@ -90,6 +90,11 @@ void CNEOBotVision::UpdatePotentiallyVisibleNPCVector( void ) */ bool CNEOBotVision::IsIgnored( CBaseEntity* subject ) const { + if (!NEORules()) // This can get called on de-init + { + return true; + } + CNEOBot* me = ( CNEOBot* )GetBot()->GetEntity(); if ( me->IsAttentionFocused() )