Fix some uninitialized variables, found with valgrind

This commit is contained in:
def 2022-05-22 00:39:52 +02:00
parent c4377bb7d9
commit 3116494f6e
5 changed files with 16 additions and 1 deletions

View file

@ -158,6 +158,7 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
while(true)
{
unsigned char aChunk[1024 * 64];
mem_zero(aChunk, sizeof(aChunk));
int Bytes = io_read(MapFile, &aChunk, sizeof(aChunk));
if(Bytes <= 0)
break;

View file

@ -4,6 +4,11 @@
#include "econ.h"
#include "netban.h"
CEcon::CEcon() :
m_Ready(false)
{
}
int CEcon::NewClientCallback(int ClientID, void *pUser)
{
CEcon *pThis = (CEcon *)pUser;

View file

@ -45,6 +45,7 @@ class CEcon
static int DelClientCallback(int ClientID, const char *pReason, void *pUser);
public:
CEcon();
IConsole *Console() { return m_pConsole; }
void Init(CConfig *pConfig, IConsole *pConsole, class CNetBan *pNetBan);

View file

@ -37,6 +37,7 @@ CStun::CProtocol::CProtocol(int Index, NETSOCKET Socket) :
m_Index(Index),
m_Socket(Socket)
{
mem_zero(&m_StunServer, sizeof(NETADDR));
// Initialize `m_Stun` with random data.
unsigned char aBuf[32];
StunMessagePrepare(aBuf, sizeof(aBuf), &m_Stun);

View file

@ -635,8 +635,15 @@ int CSaveTeam::FromString(const char *String)
m_pSavedTees = 0;
}
if(m_MembersCount)
if(m_MembersCount > 64)
{
dbg_msg("load", "savegame: team has too many players");
return 1;
}
else if(m_MembersCount)
{
m_pSavedTees = new CSaveTee[m_MembersCount];
}
for(int n = 0; n < m_MembersCount; n++)
{