source-sdk-2013
source-sdk-2013 copied to clipboard
all games: Fix segfaults in CBaseEntity when VScript is disabled
Description
When VScript is disabled using the -noscripting commandline param or when an invalid scripting language is specified, the VScript VM doesn't get initialized which shouldn't be fatal. However the server will attempt to dereference a NULL g_pScriptVM pointer due to missing checks in CBaseEntity::RunVScripts, CBaseEntity::RunPrecacheScripts and CBaseEntity::RunOnPostSpawnScripts leading to a server crash on map load if there are any entities with scripts assigned to them.
The fix for this is to make the functions return early if ValidateScriptScope fails.
Closes:
- https://github.com/ValveSoftware/Source-1-Games/issues/5122