Merge pull request #948 from jfhumann/staticFixes
Fixes motivated by Coverity #1
This commit is contained in:
commit
a0f6149d05
@ -1750,7 +1750,6 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
cLuaChunkStay * ChunkStay = new cLuaChunkStay(*Plugin);
|
|
||||||
|
|
||||||
// Read the params:
|
// Read the params:
|
||||||
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, NULL);
|
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, NULL);
|
||||||
@ -1760,8 +1759,12 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
|
|||||||
L.LogStackTrace();
|
L.LogStackTrace();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cLuaChunkStay * ChunkStay = new cLuaChunkStay(*Plugin);
|
||||||
|
|
||||||
if (!ChunkStay->AddChunks(2))
|
if (!ChunkStay->AddChunks(2))
|
||||||
{
|
{
|
||||||
|
delete ChunkStay;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,6 +744,8 @@ void cCubicNoise::CalcFloorFrac(
|
|||||||
int * a_Same, int & a_NumSame
|
int * a_Same, int & a_NumSame
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
ASSERT(a_Size > 0);
|
||||||
|
|
||||||
NOISE_DATATYPE val = a_Start;
|
NOISE_DATATYPE val = a_Start;
|
||||||
NOISE_DATATYPE dif = (a_End - a_Start) / (a_Size - 1);
|
NOISE_DATATYPE dif = (a_End - a_Start) / (a_Size - 1);
|
||||||
for (int i = 0; i < a_Size; i++)
|
for (int i = 0; i < a_Size; i++)
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
|
|
||||||
cGZipFile::cGZipFile(void) :
|
cGZipFile::cGZipFile(void) :
|
||||||
m_File(NULL)
|
m_File(NULL), m_Mode(fmRead)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +165,10 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
|
|||||||
if ((ret = ctr_drbg_init(&ctr_drbg, entropy_func, &entropy, (const unsigned char *)pers, strlen(pers))) != 0)
|
if ((ret = ctr_drbg_init(&ctr_drbg, entropy_func, &entropy, (const unsigned char *)pers, strlen(pers))) != 0)
|
||||||
{
|
{
|
||||||
LOGWARNING("cAuthenticator: ctr_drbg_init returned %d", ret);
|
LOGWARNING("cAuthenticator: ctr_drbg_init returned %d", ret);
|
||||||
|
|
||||||
|
// Free all resources which have been initialized up to this line
|
||||||
|
x509_crt_free(&cacert);
|
||||||
|
entropy_free(&entropy);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +179,10 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
LOGWARNING("cAuthenticator: x509_crt_parse returned -0x%x", -ret);
|
LOGWARNING("cAuthenticator: x509_crt_parse returned -0x%x", -ret);
|
||||||
|
|
||||||
|
// Free all resources which have been initialized up to this line
|
||||||
|
x509_crt_free(&cacert);
|
||||||
|
entropy_free(&entropy);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,6 +190,10 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
|
|||||||
if ((ret = net_connect(&server_fd, m_Server.c_str(), 443)) != 0)
|
if ((ret = net_connect(&server_fd, m_Server.c_str(), 443)) != 0)
|
||||||
{
|
{
|
||||||
LOGWARNING("cAuthenticator: Can't connect to %s: %d", m_Server.c_str(), ret);
|
LOGWARNING("cAuthenticator: Can't connect to %s: %d", m_Server.c_str(), ret);
|
||||||
|
|
||||||
|
// Free all resources which have been initialized up to this line
|
||||||
|
x509_crt_free(&cacert);
|
||||||
|
entropy_free(&entropy);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +201,13 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
|
|||||||
if ((ret = ssl_init(&ssl)) != 0)
|
if ((ret = ssl_init(&ssl)) != 0)
|
||||||
{
|
{
|
||||||
LOGWARNING("cAuthenticator: ssl_init returned %d", ret);
|
LOGWARNING("cAuthenticator: ssl_init returned %d", ret);
|
||||||
|
|
||||||
|
// Free all resources which have been initialized up to this line
|
||||||
|
x509_crt_free(&cacert);
|
||||||
|
net_close(server_fd);
|
||||||
|
ssl_free(&ssl);
|
||||||
|
entropy_free(&entropy);
|
||||||
|
memset(&ssl, 0, sizeof(ssl));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ssl_set_endpoint(&ssl, SSL_IS_CLIENT);
|
ssl_set_endpoint(&ssl, SSL_IS_CLIENT);
|
||||||
@ -203,6 +222,13 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
|
|||||||
if ((ret != POLARSSL_ERR_NET_WANT_READ) && (ret != POLARSSL_ERR_NET_WANT_WRITE))
|
if ((ret != POLARSSL_ERR_NET_WANT_READ) && (ret != POLARSSL_ERR_NET_WANT_WRITE))
|
||||||
{
|
{
|
||||||
LOGWARNING("cAuthenticator: ssl_handshake returned -0x%x", -ret);
|
LOGWARNING("cAuthenticator: ssl_handshake returned -0x%x", -ret);
|
||||||
|
|
||||||
|
// Free all resources which have been initialized up to this line
|
||||||
|
x509_crt_free(&cacert);
|
||||||
|
net_close(server_fd);
|
||||||
|
ssl_free(&ssl);
|
||||||
|
entropy_free(&entropy);
|
||||||
|
memset(&ssl, 0, sizeof(ssl));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,6 +249,13 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
|
|||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
{
|
{
|
||||||
LOGWARNING("cAuthenticator: ssl_write returned %d", ret);
|
LOGWARNING("cAuthenticator: ssl_write returned %d", ret);
|
||||||
|
|
||||||
|
// Free all resources which have been initialized up to this line
|
||||||
|
x509_crt_free(&cacert);
|
||||||
|
net_close(server_fd);
|
||||||
|
ssl_free(&ssl);
|
||||||
|
entropy_free(&entropy);
|
||||||
|
memset(&ssl, 0, sizeof(ssl));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +468,15 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_
|
|||||||
for (int i = 0; i < NumChunks; i++)
|
for (int i = 0; i < NumChunks; i++)
|
||||||
{
|
{
|
||||||
sChunkHeader * Header = new sChunkHeader;
|
sChunkHeader * Header = new sChunkHeader;
|
||||||
READ(*Header);
|
|
||||||
|
// Here we do not use the READ macro, as it does not free the resources
|
||||||
|
// allocated with new in case of error.
|
||||||
|
if (f.Read(Header, sizeof(*Header)) != sizeof(*Header))
|
||||||
|
{
|
||||||
|
LOGERROR("ERROR READING %s FROM FILE %s (line %d); file offset %d", "Header", m_FileName.c_str(), __LINE__, f.Tell());
|
||||||
|
delete Header;
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_ChunkHeaders.push_back(Header);
|
m_ChunkHeaders.push_back(Header);
|
||||||
} // for i - chunk headers
|
} // for i - chunk headers
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user