From 16a1731a325345c1bf51752dbe3d82106f7613bd Mon Sep 17 00:00:00 2001 From: Svyatoslav Date: Tue, 11 Apr 2017 17:57:47 +0300 Subject: [PATCH] sp/src/game/shared/ragdoll_shared.cpp: PVS-Studio: CWE-476 (NULL Pointer Dereference) --- sp/src/game/shared/ragdoll_shared.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/sp/src/game/shared/ragdoll_shared.cpp b/sp/src/game/shared/ragdoll_shared.cpp index e77e9a75..7b4eecc3 100644 --- a/sp/src/game/shared/ragdoll_shared.cpp +++ b/sp/src/game/shared/ragdoll_shared.cpp @@ -877,15 +877,16 @@ void CRagdollLRURetirement::Update( float frametime ) // EPISODIC VERSION for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next ) { - CBaseAnimating *pRagdoll = m_LRU[i].Get(); - next = m_LRU.Next(i); - IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); - if ( pRagdoll && (pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) ) - continue; + + CBaseAnimating *pRagdoll = m_LRU[i].Get(); if ( pRagdoll ) { + IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); + if ( pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) + continue; + // float distToPlayer = (pPlayer->GetAbsOrigin() - pRagdoll->GetAbsOrigin()).LengthSqr(); float distToPlayer = (PlayerOrigin - pRagdoll->GetAbsOrigin()).LengthSqr(); @@ -920,10 +921,13 @@ void CRagdollLRURetirement::Update( float frametime ) // EPISODIC VERSION CBaseAnimating *pRagdoll = m_LRU[i].Get(); - //Just ignore it until we're done burning/dissolving. - IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); - if ( pRagdoll && (pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) ) - continue; + if ( pRagdoll ) + { + //Just ignore it until we're done burning/dissolving. + IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); + if ( pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) + continue; + } #ifdef CLIENT_DLL m_LRU[ i ]->SUB_Remove();