Skip to content

Fix a crash when a networked entity is parented to a server-only entity#1878

Open
RaphaelIT7 wants to merge 1 commit intoValveSoftware:masterfrom
RaphaelIT7:patch-1
Open

Fix a crash when a networked entity is parented to a server-only entity#1878
RaphaelIT7 wants to merge 1 commit intoValveSoftware:masterfrom
RaphaelIT7:patch-1

Conversation

@RaphaelIT7
Copy link
Copy Markdown

Description

In the case that a networked entity was parented to a server-only entity, it would have resulted in a crash.
This happened due to pEnt-> GetNetworkParent () returning the server-only entity, but when pEdict = pParent->edict(); is executed, pEdict would become NULL since it's server-only and on the next iteration it would crash when attempting to run pEdict->GetNetworkable()

This was originally shown to me by @legokidlogan and was fixed in GMod's dev branch after he reported it there, but I think this is something that should also be fixed here.

Example code to test it with (though I couldn't test it on the latest sdk build due to the engine.dll crashing on startup?)

#if _DEBUG
void CC_Transmit_Crash( const CCommand& args )
{
	// Just some random server-only entity we can parent to
	CBaseEntity *fadeent = dynamic_cast< CBaseEntity * >( CreateEntityByName( "env_fade" ) );
	if ( !fadeent )
	{
		Warning( "Failed to create fade entity!\n" );
		return;
	}

	DispatchSpawn( fadeent );

	// We use the world since for our crash the networked entity MUST use FL_EDICT_ALWAYS
	GetWorldEntity()->SetParent( fadeent );
}
static ConCommand transmit_crash("transmit_crash", CC_Transmit_Crash, "", FCVAR_GAMEDLL);
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant