From fe8478724443573920ffc54c85145b00e0d20200 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 6 Jan 2017 21:24:59 +0500 Subject: [PATCH] Fix access to uninitialized variables. --- cl_dll/ammo.cpp | 2 +- dlls/player.cpp | 2 +- dlls/triggers.cpp | 2 +- dlls/weapons.cpp | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index fb3d8b6a..d2ff3221 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -791,7 +791,7 @@ void CHudAmmo::UserCmd_PrevWeapon( void ) //------------------------------------------------------------------------- int CHudAmmo::Draw( float flTime ) { - int a, x, y, r, g, b; + int a, x = 0, y, r, g, b; int AmmoWidth; int iCrossX; diff --git a/dlls/player.cpp b/dlls/player.cpp index 9dc6e176..4d2195ec 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3704,7 +3704,7 @@ void CBasePlayer::UpdateClientData( void ) for( int i = 1; i < 10; i++ ) { const char *pszName; - int iAmmoIndex; + int iAmmoIndex = 0; int iMaxAmmo = 0; int iCurrentAmmo = 0; int iBit = 0; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index e0611a7d..5917f4eb 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -809,7 +809,7 @@ void CTriggerEnvHurt::Spawn( void ) // When touched, a hurt trigger does DMG points of damage each half-second void CBaseTrigger::EnvTouch( CBaseEntity *pOther ) { - float fldmg; + float fldmg = 0.0f; if( !pOther->pev->takedamage ) return; diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 0ae34221..c8123305 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -744,6 +744,9 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) case IT_LIGHTNING: iId = IT_LIGHTNING; break; + default: + iId = 0; //Player is dead + break; } if( bSend ) @@ -765,7 +768,7 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) return 1; } -void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal) +void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal ) { if( UseDecrement() ) skiplocal = 1;