Browse Source

fix some AddressSanitizer issues

pull/71/head
nillerusr 2 years ago
parent
commit
29db778997
  1. 2
      engine/cmd.cpp
  2. 5
      game/client/hud_closecaption.cpp
  3. 2
      game/client/particlemgr.cpp
  4. 17
      game/server/ai_behavior_follow.cpp
  5. 2
      game/server/ai_behavior_follow.h
  6. 4
      game/server/hl2/npc_antlion.cpp
  7. 10
      game/shared/props_shared.cpp
  8. 10
      game/shared/props_shared.h

2
engine/cmd.cpp

@ -624,7 +624,7 @@ void Cmd_Exec_f( const CCommand &args ) @@ -624,7 +624,7 @@ void Cmd_Exec_f( const CCommand &args )
}
}
char buf[16384] = { 0 };
static char buf[16384] = { 0 };
int len = 0;
char *f = (char *)COM_LoadStackFile( fileName, buf, sizeof( buf ), len );
if ( !f )

5
game/client/hud_closecaption.cpp

@ -543,7 +543,7 @@ struct AsyncCaptionData_t @@ -543,7 +543,7 @@ struct AsyncCaptionData_t
data->m_nBlockNum = params.blocktoload;
data->m_nFileIndex = params.fileindex;
data->m_nBlockSize = params.blocksize;
data->m_pBlockData = new byte[ data->m_nBlockSize ];
data->m_pBlockData = new byte[ data->m_nBlockSize * sizeof(ucs2) ];
return data;
}
@ -2027,6 +2027,7 @@ public: @@ -2027,6 +2027,7 @@ public:
if ( entry.blockNum != nBlockNum )
continue;
#ifdef WIN32
const wchar_t *pIn = ( const wchar_t *)&pData->m_pBlockData[ entry.offset ];
caption->stream = new wchar_t[ entry.length >> 1 ];
@ -2034,7 +2035,7 @@ public: @@ -2034,7 +2035,7 @@ public:
#else
// we persist to disk as ucs2 so convert back to real unicode here
caption->stream = new wchar_t[ entry.length ];
V_UCS2ToUnicode( (ucs2 *)&pData->m_pBlockData[ entry.offset ], caption->stream, entry.length*sizeof(wchar_t) );
V_UCS2ToUnicode( (ucs2 *)&pData->m_pBlockData[ entry.offset ], caption->stream, entry.length << 1 );
#endif
}
}

2
game/client/particlemgr.cpp

@ -1014,7 +1014,7 @@ bool CParticleEffectBinding::RecalculateBoundingBox() @@ -1014,7 +1014,7 @@ bool CParticleEffectBinding::RecalculateBoundingBox()
CEffectMaterial* CParticleEffectBinding::GetEffectMaterial( CParticleSubTexture *pSubTexture )
{
// Hash the IMaterial pointer.
unsigned long index = (((unsigned long)pSubTexture->m_pGroup) >> 6) % EFFECT_MATERIAL_HASH_SIZE;
unsigned int index = (((unsigned int)pSubTexture->m_pGroup) >> 6) % EFFECT_MATERIAL_HASH_SIZE;
for ( CEffectMaterial *pCur=m_EffectMaterialHash[index]; pCur; pCur = pCur->m_pHashedNext )
{
if ( pCur->m_pGroup == pSubTexture->m_pGroup )

17
game/server/ai_behavior_follow.cpp

@ -53,7 +53,7 @@ struct AI_Follower_t @@ -53,7 +53,7 @@ struct AI_Follower_t
}
AIHANDLE hFollower;
int slot;
intp slot;
AI_FollowNavInfo_t navInfo;
AI_FollowGroup_t * pGroup; // backpointer for efficiency
};
@ -2561,7 +2561,7 @@ bool CAI_FollowManager::AddFollower( CBaseEntity *pTarget, CAI_BaseNPC *pFollowe @@ -2561,7 +2561,7 @@ bool CAI_FollowManager::AddFollower( CBaseEntity *pTarget, CAI_BaseNPC *pFollowe
AI_FollowSlot_t *pSlot = &pGroup->pFormation->pSlots[slot];
int i = pGroup->followers.AddToTail( );
intp i = pGroup->followers.AddToTail( );
AI_Follower_t *iterNode = &pGroup->followers[i];
iterNode->hFollower = pFollower;
@ -2569,9 +2569,8 @@ bool CAI_FollowManager::AddFollower( CBaseEntity *pTarget, CAI_BaseNPC *pFollowe @@ -2569,9 +2569,8 @@ bool CAI_FollowManager::AddFollower( CBaseEntity *pTarget, CAI_BaseNPC *pFollowe
iterNode->pGroup = pGroup;
pGroup->slotUsage.Set( slot );
CalculateFieldsFromSlot( pSlot, &iterNode->navInfo );
pHandle->m_hFollower = i;
pHandle->m_pGroup = pGroup;
return true;
@ -2641,10 +2640,10 @@ bool CAI_FollowManager::RedistributeSlots( AI_FollowGroup_t *pGroup ) @@ -2641,10 +2640,10 @@ bool CAI_FollowManager::RedistributeSlots( AI_FollowGroup_t *pGroup )
{
AI_FollowSlot_t * pSlot = &pGroup->pFormation->pSlots[bestSlot];
Vector slotPos = originFollowed + pSlot->position;
int h = pGroup->followers.Head();
int hBest = pGroup->followers.InvalidIndex();
intp h = pGroup->followers.Head();
intp hBest = pGroup->followers.InvalidIndex();
float distSqBest = FLT_MAX;
while ( h != pGroup->followers.InvalidIndex() )
{
AI_Follower_t *p = &pGroup->followers[h];
@ -2691,7 +2690,7 @@ void CAI_FollowManager::ChangeFormation( AI_FollowManagerInfoHandle_t& hInfo, AI @@ -2691,7 +2690,7 @@ void CAI_FollowManager::ChangeFormation( AI_FollowManagerInfoHandle_t& hInfo, AI
if ( pNewFormation == pGroup->pFormation )
return;
int h = pGroup->followers.Head();
intp h = pGroup->followers.Head();
while ( h != pGroup->followers.InvalidIndex() )
{
@ -2738,7 +2737,7 @@ void CAI_FollowManager::RemoveFollower( AI_FollowManagerInfoHandle_t& hInfo ) @@ -2738,7 +2737,7 @@ void CAI_FollowManager::RemoveFollower( AI_FollowManagerInfoHandle_t& hInfo )
AI_FollowGroup_t *pGroup = hInfo.m_pGroup;
AI_Follower_t* iterNode = &pGroup->followers[hInfo.m_hFollower];
int slot = iterNode->slot;
intp slot = iterNode->slot;
pGroup->slotUsage.Clear( slot );
pGroup->followers.Remove( hInfo.m_hFollower );
if ( pGroup->followers.Count() == 0 )

2
game/server/ai_behavior_follow.h

@ -100,7 +100,7 @@ struct AI_FollowGroup_t; @@ -100,7 +100,7 @@ struct AI_FollowGroup_t;
struct AI_FollowManagerInfoHandle_t
{
AI_FollowGroup_t *m_pGroup;
int m_hFollower;
intp m_hFollower;
};
//-------------------------------------

4
game/server/hl2/npc_antlion.cpp

@ -4015,8 +4015,8 @@ bool CNPC_Antlion::CorpseGib( const CTakeDamageInfo &info ) @@ -4015,8 +4015,8 @@ bool CNPC_Antlion::CorpseGib( const CTakeDamageInfo &info )
}
Vector velocity = vec3_origin;
AngularImpulse angVelocity = RandomAngularImpulse( -150, 150 );
breakablepropparams_t params( EyePosition(), GetAbsAngles(), velocity, angVelocity );
AngularImpulse angVelocity = RandomAngularImpulse( -150, 150 );
static breakablepropparams_t params( EyePosition(), GetAbsAngles(), velocity, angVelocity );
params.impactEnergyScale = 1.0f;
params.defBurstScale = 150.0f;
params.defCollisionGroup = COLLISION_GROUP_DEBRIS;

10
game/shared/props_shared.cpp

@ -951,7 +951,7 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const bre @@ -951,7 +951,7 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const bre
nSkin = pOwnerAnim->m_nSkin;
}
}
matrix3x4_t localToWorld;
static matrix3x4_t localToWorld;
CStudioHdr studioHdr;
const model_t *model = modelinfo->GetModel( modelindex );
@ -1009,7 +1009,7 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const bre @@ -1009,7 +1009,7 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const bre
if ( ( iPrecomputedBreakableCount != -1 ) && ( i >= iPrecomputedBreakableCount ) )
break;
matrix3x4_t matrix;
static matrix3x4_t matrix;
AngleMatrix( params.angles, params.origin, matrix );
CStudioHdr studioHdr;
@ -1188,7 +1188,7 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const bre @@ -1188,7 +1188,7 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const bre
Vector vecBreakableObbSize = pBreakable->CollisionProp()->OBBSize();
// Try to align the gibs along the original axis
matrix3x4_t matrix;
static matrix3x4_t matrix;
AngleMatrix( vecAngles, matrix );
AlignBoxes( &matrix, vecObbSize, vecBreakableObbSize );
MatrixAngles( matrix, vecAngles );
@ -1397,7 +1397,7 @@ CBaseEntity *CreateGibsFromList( CUtlVector<breakmodel_t> &list, int modelindex, @@ -1397,7 +1397,7 @@ CBaseEntity *CreateGibsFromList( CUtlVector<breakmodel_t> &list, int modelindex,
if ( ( iPrecomputedBreakableCount != -1 ) && ( i >= iPrecomputedBreakableCount ) )
break;
matrix3x4_t matrix;
static matrix3x4_t matrix;
AngleMatrix( params.angles, params.origin, matrix );
CStudioHdr studioHdr;
@ -1596,7 +1596,7 @@ CBaseEntity *CreateGibsFromList( CUtlVector<breakmodel_t> &list, int modelindex, @@ -1596,7 +1596,7 @@ CBaseEntity *CreateGibsFromList( CUtlVector<breakmodel_t> &list, int modelindex,
Vector vecBreakableObbSize = pBreakable->CollisionProp()->OBBSize();
// Try to align the gibs along the original axis
matrix3x4_t matrix;
static matrix3x4_t matrix;
AngleMatrix( vecAngles, matrix );
AlignBoxes( &matrix, vecObbSize, vecBreakableObbSize );
MatrixAngles( matrix, vecAngles );

10
game/shared/props_shared.h

@ -221,7 +221,7 @@ struct breakmodel_t @@ -221,7 +221,7 @@ struct breakmodel_t
struct breakablepropparams_t
{
breakablepropparams_t( const Vector &_origin, const QAngle &_angles, const Vector &_velocity, const AngularImpulse &_angularVelocity )
breakablepropparams_t( const Vector _origin, const QAngle _angles, const Vector _velocity, const AngularImpulse _angularVelocity )
: origin(_origin), angles(_angles), velocity(_velocity), angularVelocity(_angularVelocity)
{
impactEnergyScale = 0;
@ -230,10 +230,10 @@ struct breakablepropparams_t @@ -230,10 +230,10 @@ struct breakablepropparams_t
nDefaultSkin = 0;
}
const Vector &origin;
const QAngle &angles;
const Vector &velocity;
const AngularImpulse &angularVelocity;
const Vector origin;
const QAngle angles;
const Vector velocity;
const AngularImpulse angularVelocity;
float impactEnergyScale;
float defBurstScale;
int defCollisionGroup;

Loading…
Cancel
Save