Fix possible null pointer dereference.

This commit is contained in:
Andrey Akhmichin 2022-11-19 13:17:49 +05:00
parent e6424f42a7
commit 963e20c1cc
No known key found for this signature in database
GPG Key ID: 1F180D249B0643C0
2 changed files with 7 additions and 3 deletions

View File

@ -824,7 +824,7 @@ void CFuncTank::TrackTarget( void )
BOOL updateTime = FALSE, lineOfSight; BOOL updateTime = FALSE, lineOfSight;
Vector angles, direction, targetPosition, barrelEnd; Vector angles, direction, targetPosition, barrelEnd;
Vector v_right, v_up; Vector v_right, v_up;
CBaseEntity *pTarget; CBaseEntity *pTarget = NULL;
CBasePlayer* pController = NULL; CBasePlayer* pController = NULL;
// ALERT(at_console,"TrackTarget\n"); // ALERT(at_console,"TrackTarget\n");
@ -1111,7 +1111,7 @@ void CFuncTank::TrackTarget( void )
Vector forward; Vector forward;
UTIL_MakeVectorsPrivate( pev->angles, forward, NULL, NULL ); UTIL_MakeVectorsPrivate( pev->angles, forward, NULL, NULL );
if( pev->spawnflags & SF_TANK_LINEOFSIGHT ) if( pTarget && pev->spawnflags & SF_TANK_LINEOFSIGHT )
{ {
float length = direction.Length(); float length = direction.Length();
UTIL_TraceLine( barrelEnd, barrelEnd + forward * length, dont_ignore_monsters, edict(), &tr ); UTIL_TraceLine( barrelEnd, barrelEnd + forward * length, dont_ignore_monsters, edict(), &tr );

View File

@ -259,7 +259,7 @@ void CLocusBeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us
CBaseEntity *pEndEnt; CBaseEntity *pEndEnt;
Vector vecStartPos; Vector vecStartPos;
Vector vecEndPos; Vector vecEndPos;
CBeam *pBeam; CBeam *pBeam = NULL;
switch(pev->impulse) switch(pev->impulse)
{ {
@ -297,6 +297,10 @@ void CLocusBeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us
pBeam->PointsInit( vecStartPos, vecStartPos + vecEndPos ); pBeam->PointsInit( vecStartPos, vecStartPos + vecEndPos );
break; break;
} }
if( !pBeam )
return;
pBeam->SetColor( pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z ); pBeam->SetColor( pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z );
pBeam->SetBrightness( pev->renderamt ); pBeam->SetBrightness( pev->renderamt );
pBeam->SetNoise( m_iDistortion ); pBeam->SetNoise( m_iDistortion );