Skip to content

Commit 57f6bf6

Browse files
committed
fix some undefined/unspecified behaviours in multiplayer games( may help with #299 )
1 parent 2636f1a commit 57f6bf6

File tree

9 files changed

+17
-16
lines changed

9 files changed

+17
-16
lines changed

engine/NetworkStringTableItem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ bool CNetworkStringTableItem::SetUserData( int tick, int length, const void *use
199199

200200
if ( length > 0 )
201201
{
202-
m_pUserData = new unsigned char[ length ];
202+
m_pUserData = new unsigned char[ALIGN_VALUE( length, 4 )];
203203
Q_memcpy( m_pUserData, userData, length );
204204
}
205205
else

engine/downloadthread.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ void DownloadThread( void *voidPtr )
921921
// Delete rc.data, which was allocated in this thread
922922
if ( rc.data != NULL )
923923
{
924-
delete[] rc.data;
924+
free(rc.data);
925925
rc.data = NULL;
926926
}
927927

engine/pure_server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ bool CPureServerWhitelist::LoadCommandsFromKeyValues( KeyValues *kv )
226226
else
227227
Warning( "Unknown modifier in whitelist file: %s.\n", mods[i] );
228228
}
229-
mods.PurgeAndDeleteElements();
229+
mods.PurgeAndDeleteElementsArray();
230230
if (
231231
( bFromTrustedSource && ( bAllowFromDisk || bCheckCRC || bAny ) )
232232
|| ( bAny && bCheckCRC ) )

engine/sv_main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ void SV_DetermineMulticastRecipients( bool usepas, const Vector& origin, CBitVec
12271227
serverGameClients->ClientEarPosition( pClient->edict, &vecEarPosition );
12281228

12291229
int iBitNumber = CM_LeafCluster( CM_PointLeafnum( vecEarPosition ) );
1230-
if ( !(pMask[iBitNumber>>3] & (1<<(iBitNumber&7)) ) )
1230+
if ( iBitNumber < 0 || !(pMask[iBitNumber>>3] & (1<<(iBitNumber&7)) ) )
12311231
continue;
12321232

12331233
playerbits.Set( i );

engine/vengineserver_impl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ void CVEngineServer::PlaybackTempEntity( IRecipientFilter& filter, float delay,
18421842

18431843
newEvent->bits = buffer.GetNumBitsWritten();
18441844
int size = Bits2Bytes( buffer.GetNumBitsWritten() );
1845-
newEvent->pData = new byte[size];
1845+
newEvent->pData = new byte[ALIGN_VALUE(size,4)];
18461846
Q_memcpy( newEvent->pData, data, size );
18471847

18481848
// add to list

game/client/game_controls/teammenu.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void CTeamMenu::ApplySchemeSettings(IScheme *pScheme)
115115

116116
if ( *m_szMapName )
117117
{
118-
LoadMapPage( m_szMapName ); // reload the map description to pick up the color
118+
LoadMapPage( NULL ); // reload the map description to pick up the color
119119
}
120120
}
121121

@@ -185,22 +185,23 @@ void CTeamMenu::Update()
185185
void CTeamMenu::LoadMapPage( const char *mapName )
186186
{
187187
// Save off the map name so we can re-load the page in ApplySchemeSettings().
188-
Q_strncpy( m_szMapName, mapName, strlen( mapName ) + 1 );
189-
188+
if( mapName )
189+
Q_strncpy( m_szMapName, mapName, strlen( mapName ) + 1 );
190+
190191
char mapRES[ MAX_PATH ];
191192

192193
char uilanguage[ 64 ];
193194
uilanguage[0] = 0;
194195
engine->GetUILanguage( uilanguage, sizeof( uilanguage ) );
195196

196-
Q_snprintf( mapRES, sizeof( mapRES ), "resource/maphtml/%s_%s.html", mapName, uilanguage );
197+
Q_snprintf( mapRES, sizeof( mapRES ), "resource/maphtml/%s_%s.html", m_szMapName, uilanguage );
197198

198199
bool bFoundHTML = false;
199200

200201
if ( !g_pFullFileSystem->FileExists( mapRES ) )
201202
{
202203
// try english
203-
Q_snprintf( mapRES, sizeof( mapRES ), "resource/maphtml/%s_english.html", mapName );
204+
Q_snprintf( mapRES, sizeof( mapRES ), "resource/maphtml/%s_english.html", m_szMapName );
204205
}
205206
else
206207
{
@@ -240,7 +241,7 @@ void CTeamMenu::LoadMapPage( const char *mapName )
240241
#endif
241242
}
242243

243-
Q_snprintf( mapRES, sizeof( mapRES ), "maps/%s.txt", mapName);
244+
Q_snprintf( mapRES, sizeof( mapRES ), "maps/%s.txt", m_szMapName);
244245

245246
// if no map specific description exists, load default text
246247
if( !g_pFullFileSystem->FileExists( mapRES ) )

public/mathlib/ssemath.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1787,14 +1787,14 @@ FORCEINLINE fltx4 LoadAlignedSIMD( const VectorAligned & pSIMD )
17871787
return SetWToZeroSIMD( LoadAlignedSIMD(pSIMD.Base()) );
17881788
}
17891789

1790-
#ifdef __SANITIZE_ADDRESS__
1791-
static __attribute__((no_sanitize("address"))) fltx4 LoadUnalignedSIMD( const void *pSIMD )
1790+
#ifdef USING_ASAN
1791+
static NO_ASAN fltx4 LoadUnalignedSIMD( const void *pSIMD )
17921792
{
17931793
return _mm_loadu_ps( reinterpret_cast<const float *>( pSIMD ) );
17941794

17951795
}
17961796

1797-
static __attribute__((no_sanitize("address"))) fltx4 LoadUnaligned3SIMD( const void *pSIMD )
1797+
static NO_ASAN fltx4 LoadUnaligned3SIMD( const void *pSIMD )
17981798
{
17991799
return _mm_loadu_ps( reinterpret_cast<const float *>( pSIMD ) );
18001800
}

public/soundflags.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ enum
5050
// Don't change this without consulting Kelly or Wedge (sjb).
5151
#define ATTN_GUNFIRE 0.27f
5252

53-
enum soundlevel_t
53+
enum soundlevel_t : int
5454
{
5555
SNDLVL_NONE = 0,
5656

togl/linuxwin/dx9asmtogl2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ CUtlString D3DToGL::FixGLSLSwizzle( const char *pDestRegisterName, const char *p
10101010
{
10111011
bool bAbsWrapper = false; // Parameter wrapped in an abs()
10121012
bool bAbsNegative = false; // -abs()
1013-
char szSrcRegister[128];
1013+
static char szSrcRegister[128];
10141014
V_strncpy( szSrcRegister, pSrcRegisterName, sizeof(szSrcRegister) );
10151015

10161016
// Check for abs() or -abs() wrapper and strip it off during the fixup

0 commit comments

Comments
 (0)