Skip to content

Commit 7b2f53b

Browse files
Fix null read crash in CPhysHinge::Activate()
m_iszTravelSoundFwd, m_iszTravelSoundBack and m_pTravelSound aren't normally defined in most maps and can crash the game during a saverestore.
1 parent c64b09c commit 7b2f53b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/game/server/physconstraint.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,10 +940,13 @@ void CPhysHinge::Activate( void )
940940
m_soundInfo.OnActivate(this);
941941
if (m_pConstraint)
942942
{
943-
m_soundInfo.StartThinking(this,
944-
VelocitySampler::GetRelativeAngularVelocity(m_pConstraint->GetAttachedObject(), m_pConstraint->GetReferenceObject()) ,
945-
m_hinge.worldAxisDirection
943+
if (m_soundInfo.m_iszTravelSoundFwd != NULL_STRING || m_soundInfo.m_iszTravelSoundBack != NULL_STRING || m_soundInfo.m_pTravelSound != nullptr)
944+
{
945+
m_soundInfo.StartThinking(this,
946+
VelocitySampler::GetRelativeAngularVelocity(m_pConstraint->GetAttachedObject(), m_pConstraint->GetReferenceObject()) ,
947+
m_hinge.worldAxisDirection
946948
);
949+
}
947950

948951
SetThink(&CPhysHinge::SoundThink);
949952
SetNextThink( gpGlobals->curtime + m_soundInfo.getThinkRate() );

0 commit comments

Comments
 (0)