fix address sanitizer issues #2

This commit is contained in:
nillerusr 2022-05-01 20:08:32 +03:00
parent ce68fffa3b
commit 61cd8d0afc
27 changed files with 119 additions and 91 deletions

View File

@ -109,7 +109,7 @@ private:
void audioRecordingCallback( void *userdata, uint8 *stream, int len ) void audioRecordingCallback( void *userdata, uint8 *stream, int len )
{ {
VoiceRecord_SDL *voice = (VoiceRecord_SDL*)userdata; VoiceRecord_SDL *voice = (VoiceRecord_SDL*)userdata;
voice->RenderBuffer( stream, len ); voice->RenderBuffer( (char*)stream, len );
} }
VoiceRecord_SDL::VoiceRecord_SDL() : VoiceRecord_SDL::VoiceRecord_SDL() :

View File

@ -2751,7 +2751,7 @@ void CL_InitLanguageCvar()
else if( szLang ) else if( szLang )
{ {
ELanguage lang = PchLanguageICUCodeToELanguage(szLang, k_Lang_English); ELanguage lang = PchLanguageICUCodeToELanguage(szLang, k_Lang_English);
char *szShortLang = GetLanguageShortName(lang); const char *szShortLang = GetLanguageShortName(lang);
cl_language.SetValue( szShortLang ); cl_language.SetValue( szShortLang );
} }
else else

View File

@ -1816,14 +1816,14 @@ void CClientState::FinishSignonState_New()
// //
// This is pretty janky, but doesn't really have any cost (and even makes our one-frozen-frame load screen slightly // This is pretty janky, but doesn't really have any cost (and even makes our one-frozen-frame load screen slightly
// less likely to trigger OS "not responding" warnings) // less likely to trigger OS "not responding" warnings)
extern void V_RenderVGuiOnly(); // extern void V_RenderVGuiOnly();
V_RenderVGuiOnly(); // V_RenderVGuiOnly();
// Before we do anything with the whitelist, make sure we have the proper map pack mounted // Before we do anything with the whitelist, make sure we have the proper map pack mounted
// this will load the .bsp by setting the world model the string list at the hardcoded index 1. // this will load the .bsp by setting the world model the string list at the hardcoded index 1.
cl.SetModel( 1 ); cl.SetModel( 1 );
V_RenderVGuiOnly(); //V_RenderVGuiOnly();
// Check for a new whitelist. It's good to do it early in the connection process here because if we wait until later, // Check for a new whitelist. It's good to do it early in the connection process here because if we wait until later,
// the client may have loaded some files w/o the proper whitelist restrictions and we'd have to reload them. // the client may have loaded some files w/o the proper whitelist restrictions and we'd have to reload them.

View File

@ -865,6 +865,7 @@ CConPanel::CConPanel( vgui::Panel *parent ) : CBasePanel( parent, "CConPanel" )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
CConPanel::~CConPanel( void ) CConPanel::~CConPanel( void )
{ {
g_pConPanel = NULL;
} }
void CConPanel::Con_NPrintf( int idx, const char *msg ) void CConPanel::Con_NPrintf( int idx, const char *msg )

View File

@ -1289,7 +1289,7 @@ public:
SaveMsg( "DirectoryCopy: AsyncAppend %s, %s\n", szName, pDestFileName ); SaveMsg( "DirectoryCopy: AsyncAppend %s, %s\n", szName, pDestFileName );
g_pFileSystem->AsyncAppend( pDestFileName, memcpy( new char[MAX_PATH], list[i].szFileName, MAX_PATH), MAX_PATH, true ); // Filename can only be as long as a map name + extension g_pFileSystem->AsyncAppend( pDestFileName, memcpy( new char[MAX_PATH], list[i].szFileName, MAX_PATH), MAX_PATH, true ); // Filename can only be as long as a map name + extension
g_pFileSystem->AsyncAppend( pDestFileName, new int(fileSize), sizeof(int), true ); g_pFileSystem->AsyncAppend( pDestFileName, memcpy( new char[sizeof(int)], &fileSize, sizeof(int)), sizeof(int), true );
g_pFileSystem->AsyncAppendFile( pDestFileName, szName ); g_pFileSystem->AsyncAppendFile( pDestFileName, szName );
} }
} }

View File

@ -2071,11 +2071,11 @@ public:
private: private:
static const Vector m_pNormal; static Vector m_pNormal;
static float m_Dist; static float m_Dist;
}; };
const Vector CClipPlane::m_pNormal; Vector CClipPlane::m_pNormal;
float CClipPlane::m_Dist; float CClipPlane::m_Dist;
static inline void ClampTexCoord( ShadowVertex_t *pInVertex, ShadowVertex_t *pOutVertex ) static inline void ClampTexCoord( ShadowVertex_t *pInVertex, ShadowVertex_t *pOutVertex )

View File

@ -18,6 +18,8 @@
class CMaterial_QueueFriendly : public IMaterialInternal //wraps a CMaterial with queue friendly functions for game/engine code. materialsystem/shaderapi code should use CMaterial directly. class CMaterial_QueueFriendly : public IMaterialInternal //wraps a CMaterial with queue friendly functions for game/engine code. materialsystem/shaderapi code should use CMaterial directly.
{ {
public: public:
CMaterial_QueueFriendly() : m_pRealTimeVersion(NULL) {}
virtual const char * GetName() const; virtual const char * GetName() const;
virtual const char * GetTextureGroupName() const; virtual const char * GetTextureGroupName() const;
virtual PreviewImageRetVal_t GetPreviewImageProperties( int *width, int *height, ImageFormat *imageFormat, bool* isTranslucent ) const; virtual PreviewImageRetVal_t GetPreviewImageProperties( int *width, int *height, ImageFormat *imageFormat, bool* isTranslucent ) const;

View File

@ -6301,27 +6301,16 @@ int CShaderAPIDx8::GetCurrentDynamicVBSize( void )
FORCEINLINE void CShaderAPIDx8::SetVertexShaderConstantInternal( int var, float const* pVec, int numVecs, bool bForce ) FORCEINLINE void CShaderAPIDx8::SetVertexShaderConstantInternal( int var, float const* pVec, int numVecs, bool bForce )
{ {
Assert( numVecs > 0 );
Assert( pVec ); Assert( pVec );
// DX8 asm shaders use a constant mapping which has transforms and vertex shader if ( IsPC() || IsPS3() )
// specific constants shifted down by 10 constants (two 5-constant light structures)
if ( IsPC() )
{ {
if ( (g_pHardwareConfig->Caps().m_nDXSupportLevel < 90) && (var >= VERTEX_SHADER_MODULATION_COLOR) )
{
var -= 10;
}
Assert( var + numVecs <= g_pHardwareConfig->NumVertexShaderConstants() ); Assert( var + numVecs <= g_pHardwareConfig->NumVertexShaderConstants() );
if ( !bForce ) if ( !bForce && memcmp( pVec, &m_DynamicState.m_pVectorVertexShaderConstant[var], numVecs * 4 * sizeof( float ) ) == 0 )
{ return;
int skip = 0;
numVecs = AdjustUpdateRange( pVec, &m_DesiredState.m_pVectorVertexShaderConstant[var], numVecs, &skip );
if ( !numVecs )
return;
var += skip;
pVec += skip * 4;
}
Dx9Device()->SetVertexShaderConstantF( var, pVec, numVecs ); Dx9Device()->SetVertexShaderConstantF( var, pVec, numVecs );
memcpy( &m_DynamicState.m_pVectorVertexShaderConstant[var], pVec, numVecs * 4 * sizeof(float) ); memcpy( &m_DynamicState.m_pVectorVertexShaderConstant[var], pVec, numVecs * 4 * sizeof(float) );
} }
@ -6330,12 +6319,10 @@ FORCEINLINE void CShaderAPIDx8::SetVertexShaderConstantInternal( int var, float
Assert( var + numVecs <= g_pHardwareConfig->NumVertexShaderConstants() ); Assert( var + numVecs <= g_pHardwareConfig->NumVertexShaderConstants() );
} }
memcpy( &m_DesiredState.m_pVectorVertexShaderConstant[var], pVec, numVecs * 4 * sizeof(float) ); if ( IsX360() && var + numVecs > m_MaxVectorVertexShaderConstant )
m_MaxVectorVertexShaderConstant = var + numVecs;
if ( IsX360() ) memcpy( &m_DesiredState.m_pVectorVertexShaderConstant[var], pVec, numVecs * 4 * sizeof(float) );
{
m_MaxVectorVertexShaderConstant = max( m_MaxVectorVertexShaderConstant, var + numVecs );
}
} }
@ -6417,29 +6404,40 @@ FORCEINLINE void CShaderAPIDx8::SetPixelShaderConstantInternal( int nStartConst,
{ {
Assert( nStartConst + nNumConsts <= g_pHardwareConfig->NumPixelShaderConstants() ); Assert( nStartConst + nNumConsts <= g_pHardwareConfig->NumPixelShaderConstants() );
if ( IsPC() ) if ( IsPC() || IsPS3() )
{ {
if ( ! bForce ) if ( !bForce )
{ {
int skip = 0; DWORD* pSrc = (DWORD*)pValues;
nNumConsts = AdjustUpdateRange( pValues, &m_DesiredState.m_pVectorPixelShaderConstant[nStartConst], nNumConsts, &skip ); DWORD* pDst = (DWORD*)&m_DesiredState.m_pVectorPixelShaderConstant[nStartConst];
while( nNumConsts && ( pSrc[0] == pDst[0] ) && ( pSrc[1] == pDst[1] ) && ( pSrc[2] == pDst[2] ) && ( pSrc[3] == pDst[3] ) )
{
pSrc += 4;
pDst += 4;
nNumConsts--;
nStartConst++;
}
if ( !nNumConsts ) if ( !nNumConsts )
return; return;
nStartConst += skip; pValues = reinterpret_cast< float const * >( pSrc );
pValues += skip * 4;
} }
Dx9Device()->SetPixelShaderConstantF( nStartConst, pValues, nNumConsts ); Dx9Device()->SetPixelShaderConstantF( nStartConst, pValues, nNumConsts );
memcpy( &m_DynamicState.m_pVectorPixelShaderConstant[nStartConst], pValues, nNumConsts * 4 * sizeof(float) ); memcpy( &m_DynamicState.m_pVectorPixelShaderConstant[nStartConst], pValues, nNumConsts * 4 * sizeof(float) );
} }
memcpy( &m_DesiredState.m_pVectorPixelShaderConstant[nStartConst], pValues, nNumConsts * 4 * sizeof(float) ); if ( IsX360() && nStartConst + nNumConsts > m_MaxVectorPixelShaderConstant )
if ( IsX360() )
{ {
m_MaxVectorPixelShaderConstant = max( m_MaxVectorPixelShaderConstant, nStartConst + nNumConsts ); m_MaxVectorPixelShaderConstant = nStartConst + nNumConsts;
Assert( m_MaxVectorPixelShaderConstant <= 32 ); Assert( m_MaxVectorPixelShaderConstant <= 32 );
if ( m_MaxVectorPixelShaderConstant > 32 )
{
// NOTE! There really are 224 pixel shader constants on the 360, but we do an optimization that only blasts the first 32 always.
Error( "Don't use more then the first 32 pixel shader constants on the 360!" );
}
} }
memcpy( &m_DesiredState.m_pVectorPixelShaderConstant[nStartConst], pValues, nNumConsts * 4 * sizeof(float) );
} }
void CShaderAPIDx8::SetPixelShaderConstant( int var, float const* pVec, int numVecs, bool bForce ) void CShaderAPIDx8::SetPixelShaderConstant( int var, float const* pVec, int numVecs, bool bForce )

View File

@ -562,7 +562,7 @@ void CShaderDeviceMgrDx8::CheckVendorDependentAlphaToCoverage( HardwareCaps_t *p
ConVar mat_hdr_level( "mat_hdr_level", "2", FCVAR_ARCHIVE ); ConVar mat_hdr_level( "mat_hdr_level", "2", FCVAR_ARCHIVE );
ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT ); ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT );
#ifdef DX_TO_GL_ABSTRACTION #ifdef DX_TO_GL_ABSTRACTION
ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "20", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ); ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "40", FCVAR_CHEAT );
#else #else
ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT ); ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT );
#endif #endif

View File

@ -198,7 +198,7 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE )
vParms.y = 4000.0f; // arbitrary far vParms.y = 4000.0f; // arbitrary far
vParms.z = 0.0f; vParms.z = 0.0f;
vParms.w = 0.0f; vParms.w = 0.0f;
pShaderAPI->SetPixelShaderConstant( 1, vParms.Base(), 2 ); pShaderAPI->SetPixelShaderConstant( 1, vParms.Base(), 1 );
} // DYNAMIC_STATE } // DYNAMIC_STATE

View File

@ -132,15 +132,16 @@ BEGIN_VS_SHADER_FLAGS( ParticleSphere_DX9, "Help for BumpmappedEnvMap", SHADER_N
// (It does this by seeing if the intensity*1/distSqr is > 1. If so, then it scales it so // (It does this by seeing if the intensity*1/distSqr is > 1. If so, then it scales it so
// it is equal to 1). // it is equal to 1).
const float *f = params[LIGHT_COLOR]->GetVecValue(); const float *f = params[LIGHT_COLOR]->GetVecValue();
Vector vLightColor( f[0], f[1], f[2] ); Vector4D vLightColor( f[0], f[1], f[2], 0.f );
float flScale = max( vLightColor.x, max( vLightColor.y, vLightColor.z ) ); float flScale = max( vLightColor.x, max( vLightColor.y, vLightColor.z ) );
if ( flScale < 0.01f ) if ( flScale < 0.01f )
flScale = 0.01f; flScale = 0.01f;
float vScaleVec[3] = { flScale, flScale, flScale };
Vector4D vScaleVec = { flScale, flScale, flScale, 0.f };
vLightColor /= flScale; vLightColor /= flScale;
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, vLightColor.Base() ); pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, vLightColor.Base() );
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, vScaleVec ); pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, vScaleVec.Base() );
pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS ); pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );

View File

@ -635,14 +635,18 @@ bool IsOBBIntersectingOBB( const Vector &vecOrigin1, const QAngle &vecAngles1, c
} }
// NOTE: This is only very slightly faster on high end PCs and x360 // NOTE: This is only very slightly faster on high end PCs and x360
#ifdef __SANITIZE_ADDRESS__
#define USE_SIMD_RAY_CHECKS 0
#else
#define USE_SIMD_RAY_CHECKS 1 #define USE_SIMD_RAY_CHECKS 1
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// returns true if there's an intersection between box and ray // returns true if there's an intersection between box and ray
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool FASTCALL IsBoxIntersectingRay( const Vector& boxMin, const Vector& boxMax, bool FASTCALL IsBoxIntersectingRay( const Vector& boxMin, const Vector& boxMax,
const Vector& origin, const Vector& vecDelta, float flTolerance ) const Vector& origin, const Vector& vecDelta, float flTolerance )
{ {
#if USE_SIMD_RAY_CHECKS #if USE_SIMD_RAY_CHECKS
// Load the unaligned ray/box parameters into SIMD registers // Load the unaligned ray/box parameters into SIMD registers
fltx4 start = LoadUnaligned3SIMD(origin.Base()); fltx4 start = LoadUnaligned3SIMD(origin.Base());
@ -695,7 +699,7 @@ bool FASTCALL IsBoxIntersectingRay( const Vector& boxMin, const Vector& boxMax,
return IsAllZeros(separation); return IsAllZeros(separation);
#else #else
// On the x360, we force use of the SIMD functions. // On the x360, we force use of the SIMD functions.
#if defined(_X360) #if defined(_X360)
if (IsX360()) if (IsX360())
{ {
fltx4 delta = LoadUnaligned3SIMD(vecDelta.Base()); fltx4 delta = LoadUnaligned3SIMD(vecDelta.Base());
@ -766,7 +770,7 @@ bool FASTCALL IsBoxIntersectingRay( const Vector& boxMin, const Vector& boxMax,
bool FASTCALL IsBoxIntersectingRay( const Vector& boxMin, const Vector& boxMax, bool FASTCALL IsBoxIntersectingRay( const Vector& boxMin, const Vector& boxMax,
const Vector& origin, const Vector& vecDelta, const Vector& origin, const Vector& vecDelta,
const Vector& vecInvDelta, float flTolerance ) const Vector& vecInvDelta, float flTolerance )
{ {
#if USE_SIMD_RAY_CHECKS #if USE_SIMD_RAY_CHECKS
// Load the unaligned ray/box parameters into SIMD registers // Load the unaligned ray/box parameters into SIMD registers
fltx4 start = LoadUnaligned3SIMD(origin.Base()); fltx4 start = LoadUnaligned3SIMD(origin.Base());

View File

@ -431,7 +431,7 @@ public:
{ {
for ( int i = 0; i < m_Names.Count(); i++ ) for ( int i = 0; i < m_Names.Count(); i++ )
{ {
delete m_Names[i]; delete[] m_Names[i];
} }
} }

View File

@ -429,7 +429,7 @@ void CDispCollTree::AABBTree_CreateLeafs( void )
} }
} }
void CDispCollTree::AABBTree_GenerateBoxes_r( int nodeIndex, Vector *pMins, Vector *pMaxs ) void __attribute__((no_sanitize("address"))) CDispCollTree::AABBTree_GenerateBoxes_r( int nodeIndex, Vector *pMins, Vector *pMaxs )
{ {
// leaf // leaf
ClearBounds( *pMins, *pMaxs ); ClearBounds( *pMins, *pMaxs );

View File

@ -195,9 +195,7 @@ inline ConCommandBase * ICvar::Iterator::Get( void )
// don't have to include tier1.h // don't have to include tier1.h
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// These are marked DLL_EXPORT for Linux. extern ICvar *cvar;
DLL_EXPORT ICvar *cvar;
extern ICvar *g_pCVar; extern ICvar *g_pCVar;
#endif // ICVAR_H #endif // ICVAR_H

View File

@ -23,7 +23,7 @@
#define USE_STDC_FOR_SIMD 0 #define USE_STDC_FOR_SIMD 0
#endif #endif
#if (!defined (__arm__) && !defined(_X360) && (USE_STDC_FOR_SIMD == 0)) #if !(defined(_X360) && (USE_STDC_FOR_SIMD == 0))
#define _SSE1 1 #define _SSE1 1
#endif #endif

View File

@ -83,7 +83,7 @@ Studio models are position independent, so the cache manager can move them.
#define MAXSTUDIOFLEXDESC 1024 // maximum number of low level flexes (actual morph targets) #define MAXSTUDIOFLEXDESC 1024 // maximum number of low level flexes (actual morph targets)
#define MAXSTUDIOFLEXCTRL 96 // maximum number of flexcontrollers (input sliders) #define MAXSTUDIOFLEXCTRL 96 // maximum number of flexcontrollers (input sliders)
#define MAXSTUDIOPOSEPARAM 24 #define MAXSTUDIOPOSEPARAM 24
#define MAXSTUDIOBONECTRLS 4 #define MAXSTUDIOBONECTRLS 5
#define MAXSTUDIOANIMBLOCKS 256 #define MAXSTUDIOANIMBLOCKS 256
#define MAXSTUDIOBONEBITS 7 // NOTE: MUST MATCH MAXSTUDIOBONES #define MAXSTUDIOBONEBITS 7 // NOTE: MUST MATCH MAXSTUDIOBONES

View File

@ -1182,7 +1182,11 @@ private:
class ALIGN8 PLATFORM_CLASS CThreadSpinRWLock class ALIGN8 PLATFORM_CLASS CThreadSpinRWLock
{ {
public: public:
CThreadSpinRWLock() { COMPILE_TIME_ASSERT( sizeof( LockInfo_t ) == sizeof( int64 ) ); Assert( (intp)this % 8 == 0 ); memset( this, 0, sizeof( *this ) ); } CThreadSpinRWLock()
{
COMPILE_TIME_ASSERT( sizeof( LockInfo_t ) == sizeof( int64 ) );
Assert( (intp)this % 8 == 0 );
}
bool TryLockForWrite(); bool TryLockForWrite();
bool TryLockForRead(); bool TryLockForRead();
@ -1200,11 +1204,18 @@ public:
void UnlockWrite() const { const_cast<CThreadSpinRWLock *>(this)->UnlockWrite(); } void UnlockWrite() const { const_cast<CThreadSpinRWLock *>(this)->UnlockWrite(); }
private: private:
struct LockInfo_t struct LockInfo_t
{
LockInfo_t(uint32 thread_id = 0, int readers = 0)
{ {
uint32 m_writerId; m_writerId = thread_id;
int m_nReaders; m_nReaders = readers;
}; }
uint32 m_writerId;
int m_nReaders;
};
bool AssignIf( const LockInfo_t &newValue, const LockInfo_t &comperand ); bool AssignIf( const LockInfo_t &newValue, const LockInfo_t &comperand );
bool TryLockForWrite( const uint32 threadId ); bool TryLockForWrite( const uint32 threadId );
@ -1751,8 +1762,8 @@ inline bool CThreadSpinRWLock::TryLockForWrite( const uint32 threadId )
return false; return false;
} }
static const LockInfo_t oldValue = { 0, 0 }; static const LockInfo_t oldValue( 0, 0 );
LockInfo_t newValue = { threadId, 0 }; LockInfo_t newValue( threadId, 0 );
const bool bSuccess = AssignIf( newValue, oldValue ); const bool bSuccess = AssignIf( newValue, oldValue );
#if defined(_X360) #if defined(_X360)
if ( bSuccess ) if ( bSuccess )

View File

@ -231,7 +231,7 @@ public:
#endif #endif
} }
TSLNodeBase_t *Pop() __attribute__((no_sanitize("address"))) TSLNodeBase_t *Pop()
{ {
#ifdef USE_NATIVE_SLIST #ifdef USE_NATIVE_SLIST
#ifdef _X360 #ifdef _X360

View File

@ -30,8 +30,7 @@ class IProcessUtils;
// allowing link libraries to access tier1 library interfaces // allowing link libraries to access tier1 library interfaces
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// These are marked DLL_EXPORT for Linux. extern ICvar *cvar;
DLL_EXPORT ICvar *cvar;
extern ICvar *g_pCVar; extern ICvar *g_pCVar;
extern IProcessUtils *g_pProcessUtils; extern IProcessUtils *g_pProcessUtils;

View File

@ -142,9 +142,9 @@ static bool IsWin98OrOlder()
static bool CheckSSETechnology(void) static bool CheckSSETechnology(void)
{ {
#if defined( __ARM__ ) #if defined(__SANITIZE_ADDRESS__)
return false; return false;
#elif defined( _X360 ) || defined( _PS3 ) #elif defined( _X360 ) || defined( _PS3 ) || defined (__arm__)
return true; return true;
#else #else
if ( IsWin98OrOlder() ) { if ( IsWin98OrOlder() ) {
@ -162,8 +162,10 @@ static bool CheckSSETechnology(void)
static bool CheckSSE2Technology(void) static bool CheckSSE2Technology(void)
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#elif defined (__arm__)
return true;
#else #else
unsigned long eax,ebx,edx,unused; unsigned long eax,ebx,edx,unused;
if ( !cpuid(1,eax,ebx,unused,edx) ) if ( !cpuid(1,eax,ebx,unused,edx) )
@ -175,8 +177,10 @@ static bool CheckSSE2Technology(void)
bool CheckSSE3Technology(void) bool CheckSSE3Technology(void)
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#elif defined (__arm__)
return true;
#else #else
unsigned long eax,ebx,edx,ecx; unsigned long eax,ebx,edx,ecx;
if( !cpuid(1,eax,ebx,ecx,edx) ) if( !cpuid(1,eax,ebx,ecx,edx) )
@ -188,8 +192,10 @@ bool CheckSSE3Technology(void)
bool CheckSSSE3Technology(void) bool CheckSSSE3Technology(void)
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#elif defined (__arm__)
return true;
#else #else
// SSSE 3 is implemented by both Intel and AMD // SSSE 3 is implemented by both Intel and AMD
// detection is done the same way for both vendors // detection is done the same way for both vendors
@ -203,8 +209,10 @@ bool CheckSSSE3Technology(void)
bool CheckSSE41Technology(void) bool CheckSSE41Technology(void)
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#elif defined (__arm__)
return true;
#else #else
// SSE 4.1 is implemented by both Intel and AMD // SSE 4.1 is implemented by both Intel and AMD
// detection is done the same way for both vendors // detection is done the same way for both vendors
@ -219,8 +227,10 @@ bool CheckSSE41Technology(void)
bool CheckSSE42Technology(void) bool CheckSSE42Technology(void)
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#elif defined (__arm__)
return true;
#else #else
// SSE4.2 is an Intel-only feature // SSE4.2 is an Intel-only feature
@ -239,8 +249,10 @@ bool CheckSSE42Technology(void)
bool CheckSSE4aTechnology( void ) bool CheckSSE4aTechnology( void )
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#elif defined (__arm__)
return true;
#else #else
// SSE 4a is an AMD-only feature // SSE 4a is an AMD-only feature
@ -259,7 +271,7 @@ bool CheckSSE4aTechnology( void )
static bool Check3DNowTechnology(void) static bool Check3DNowTechnology(void)
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined (__arm__) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#else #else
unsigned long eax, unused; unsigned long eax, unused;
@ -279,7 +291,7 @@ static bool Check3DNowTechnology(void)
static bool CheckCMOVTechnology() static bool CheckCMOVTechnology()
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined (__arm__) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#else #else
unsigned long eax,ebx,edx,unused; unsigned long eax,ebx,edx,unused;
@ -292,7 +304,7 @@ static bool CheckCMOVTechnology()
static bool CheckFCMOVTechnology(void) static bool CheckFCMOVTechnology(void)
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined (__arm__) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#else #else
unsigned long eax,ebx,edx,unused; unsigned long eax,ebx,edx,unused;
@ -305,7 +317,7 @@ static bool CheckFCMOVTechnology(void)
static bool CheckRDTSCTechnology(void) static bool CheckRDTSCTechnology(void)
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 ) || defined (__arm__) || defined(__SANITIZE_ADDRESS__)
return false; return false;
#else #else
unsigned long eax,ebx,edx,unused; unsigned long eax,ebx,edx,unused;
@ -321,11 +333,13 @@ const tchar* GetProcessorVendorId()
{ {
#if defined( _X360 ) || defined( _PS3 ) #if defined( _X360 ) || defined( _PS3 )
return "PPC"; return "PPC";
#elif defined ( __arm__ )
return "ARM";
#else #else
unsigned long unused, VendorIDRegisters[3]; unsigned long unused, VendorIDRegisters[3];
static tchar VendorID[13]; static tchar VendorID[13];
memset( VendorID, 0, sizeof(VendorID) ); memset( VendorID, 0, sizeof(VendorID) );
if ( !cpuid(0,unused, VendorIDRegisters[0], VendorIDRegisters[2], VendorIDRegisters[1] ) ) if ( !cpuid(0,unused, VendorIDRegisters[0], VendorIDRegisters[2], VendorIDRegisters[1] ) )
{ {
@ -375,7 +389,7 @@ static bool HTSupported(void)
// Check to see if this is a Pentium 4 or later processor // Check to see if this is a Pentium 4 or later processor
if (((reg_eax & FAMILY_ID) == PENTIUM4_ID) || (reg_eax & EXT_FAMILY_ID)) if (((reg_eax & FAMILY_ID) == PENTIUM4_ID) || (reg_eax & EXT_FAMILY_ID))
if (vendor_id[0] == 'uneG' && vendor_id[1] == 'Ieni' && vendor_id[2] == 'letn') if (vendor_id[0] == 0x756E6547 && vendor_id[1] == 0x49656E69 && vendor_id[2] == 0x6C65746E)
return (reg_edx & HT_BIT) != 0; // Genuine Intel Processor with Hyper-Threading Technology return (reg_edx & HT_BIT) != 0; // Genuine Intel Processor with Hyper-Threading Technology
return false; // This is not a genuine Intel processor. return false; // This is not a genuine Intel processor.
@ -391,7 +405,7 @@ static uint8 LogicalProcessorsPerPackage(void)
// EBX[23:16] indicate number of logical processors per package // EBX[23:16] indicate number of logical processors per package
const unsigned NUM_LOGICAL_BITS = 0x00FF0000; const unsigned NUM_LOGICAL_BITS = 0x00FF0000;
unsigned long unused, reg_ebx = 0; unsigned long unused, reg_ebx = 0;
if ( !HTSupported() ) if ( !HTSupported() )
return 1; return 1;

View File

@ -1516,7 +1516,7 @@ void CVProfile::Term()
{ {
delete [] m_pBudgetGroups[i].m_pName; delete [] m_pBudgetGroups[i].m_pName;
} }
delete m_pBudgetGroups; delete[] m_pBudgetGroups;
m_nBudgetGroupNames = m_nBudgetGroupNamesAllocated = 0; m_nBudgetGroupNames = m_nBudgetGroupNamesAllocated = 0;
m_pBudgetGroups = NULL; m_pBudgetGroups = NULL;

View File

@ -6,12 +6,16 @@
// $NoKeywords: $ // $NoKeywords: $
//=============================================================================// //=============================================================================//
#if defined __SANITIZE_ADDRESS__
#if defined (__arm__)
bool CheckMMXTechnology(void) { return false; } bool CheckMMXTechnology(void) { return false; }
bool CheckSSETechnology(void) { return false; } bool CheckSSETechnology(void) { return false; }
bool CheckSSE2Technology(void) { return false; } bool CheckSSE2Technology(void) { return false; }
bool Check3DNowTechnology(void) { return false; } bool Check3DNowTechnology(void) { return false; }
#elif defined (__arm__)
bool CheckMMXTechnology(void) { return true; }
bool CheckSSETechnology(void) { return true; }
bool CheckSSE2Technology(void) { return true; }
bool Check3DNowTechnology(void) { return false; }
#else #else
#define cpuid(in,a,b,c,d) \ #define cpuid(in,a,b,c,d) \

View File

@ -1788,14 +1788,14 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force )
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f }; 0.0f, 0.0f, 0.0f };
static int indices[] = { 0, 1, 2 }; static short indices[] = { 0, 1, 2 };
gGL->glEnableVertexAttribArray( 0 ); gGL->glEnableVertexAttribArray( 0 );
gGL->glVertexAttribPointer( 0, 3, GL_FLOAT, 0, 0, posns ); gGL->glVertexAttribPointer( 0, 3, GL_FLOAT, 0, 0, posns );
gGL->glDrawRangeElements( GL_TRIANGLES, 0, 3, 3, GL_UNSIGNED_INT, indices); gGL->glDrawRangeElements( GL_TRIANGLES, 0, 2, 3, GL_UNSIGNED_SHORT, indices);
gGL->glDisableVertexAttribArray( 0 ); gGL->glDisableVertexAttribArray( 0 );

View File

@ -647,8 +647,6 @@ void CPhysicsObject::SetInertia( const Vector &inertia )
ri.k[1] = IVP_Inline_Math::fabsd(ri.k[1]); ri.k[1] = IVP_Inline_Math::fabsd(ri.k[1]);
ri.k[2] = IVP_Inline_Math::fabsd(ri.k[2]); ri.k[2] = IVP_Inline_Math::fabsd(ri.k[2]);
if( ri.k[0] > 1e14f ) ri.k[0] = 1e14f; if( ri.k[1] > 1e14f ) ri.k[1] = 1e14f; if( ri.k[2] > 1e14f ) ri.k[2] = 1e14f;
m_pObject->get_core()->set_rotation_inertia( &ri ); m_pObject->get_core()->set_rotation_inertia( &ri );
} }

View File

@ -174,8 +174,7 @@ void CVPhysicsParse::ParseSolid( solid_t *pSolid, IVPhysicsKeyHandler *unknownKe
} }
else if ( !Q_stricmp( key, "inertia" ) ) else if ( !Q_stricmp( key, "inertia" ) )
{ {
float inertia = atof(value); pSolid->params.inertia = atof(value);
pSolid->params.inertia = (inertia > 1e14f) ? 1e14f : inertia;
} }
else if ( !Q_stricmp( key, "damping" ) ) else if ( !Q_stricmp( key, "damping" ) )
{ {
@ -469,8 +468,7 @@ void CVPhysicsParse::ParseVehicleWheel( vehicle_wheelparams_t &wheel )
} }
else if ( !Q_stricmp( key, "inertia" ) ) else if ( !Q_stricmp( key, "inertia" ) )
{ {
float inertia = atof(value); wheel.inertia = atof(value);
wheel.inertia = (inertia > 1e14f) ? 1e14f : inertia;
} }
else if ( !Q_stricmp( key, "damping" ) ) else if ( !Q_stricmp( key, "damping" ) )
{ {

View File

@ -473,11 +473,11 @@ CPackedStore::~CPackedStore( void )
} }
// Free the FindFirst cache data // Free the FindFirst cache data
m_directoryList.PurgeAndDeleteElements(); m_directoryList.PurgeAndDeleteElementsArray();
FOR_EACH_MAP( m_dirContents, i ) FOR_EACH_MAP( m_dirContents, i )
{ {
m_dirContents[i]->PurgeAndDeleteElements(); m_dirContents[i]->PurgeAndDeleteElementsArray();
delete m_dirContents[i]; delete m_dirContents[i];
} }
} }