Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Opposing Force] Game crash when colliding with spore nade if the owner of the entity is NULL #3056

Open
hobokenn opened this issue Feb 22, 2021 · 1 comment

Comments

@hobokenn
Copy link

How to reproduce: you need to gib a shock trooper after a nade throw, then save/load and catch the nade. I found the best place to do that is in the boss fight map, you can bait their nades easily by stepping back from the railing or just generally taking cover somewhere.

@SamVanheer
Copy link

This happens because the player's TakeDamage method is called with a null attacker.

When this line:

CBaseEntity *pAttacker = CBaseEntity::Instance(pevAttacker);

is executed it tries to access pevAttacker->pContainingEntity:

static CBaseEntity *Instance( entvars_t *pev ) { return Instance( ENT( pev ) ); }

inline edict_t *ENT(const entvars_t *pev) { return pev->pContainingEntity; }

Since the attacker is null this crashes the program.

CBaseEntity::Instance has a failsafe that returns the world if the given entity is null, but this only works if the overload that takes an edict_t* is called directly. Since this calls the entvars_t* overload it crashes. A foolproof fix should apply the same failsafe to all overloads that could be given a null pointer:

static CBaseEntity *Instance( entvars_t *pev )
{
	if (!pev)
		return Instance(ENT(0));

	return Instance(ENT(pev));
}

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

No branches or pull requests

3 participants