mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Fix segmentation fault when creating sql tables failed
`GameServer()->OnShutdown(true);` (which would wait on running threads to exit) wasn't called if an error occured in the server init. Therefore `CServer` was freed before the init-thread finished executing, causing a use after free from `CSqlConnector::ms_ppSqlReadServers` pointing to `CServer->m_apSqlReadServers`.
This commit is contained in:
parent
6fcb8abbd0
commit
f5ac6eea56
|
@ -2063,7 +2063,7 @@ int CServer::Run()
|
||||||
GameServer()->OnInit();
|
GameServer()->OnInit();
|
||||||
if(ErrorShutdown())
|
if(ErrorShutdown())
|
||||||
{
|
{
|
||||||
return 1;
|
m_RunServer = false;
|
||||||
}
|
}
|
||||||
str_format(aBuf, sizeof(aBuf), "version %s", GameServer()->NetVersion());
|
str_format(aBuf, sizeof(aBuf), "version %s", GameServer()->NetVersion());
|
||||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||||
|
@ -2281,6 +2281,7 @@ int CServer::Run()
|
||||||
const char *pDisconnectReason = "Server shutdown";
|
const char *pDisconnectReason = "Server shutdown";
|
||||||
if(ErrorShutdown())
|
if(ErrorShutdown())
|
||||||
{
|
{
|
||||||
|
dbg_msg("server", "shutdown from game server (%s)", m_aErrorShutdownReason);
|
||||||
pDisconnectReason = m_aErrorShutdownReason;
|
pDisconnectReason = m_aErrorShutdownReason;
|
||||||
}
|
}
|
||||||
// disconnect all clients on shutdown
|
// disconnect all clients on shutdown
|
||||||
|
|
Loading…
Reference in a new issue