mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
3297: Fix memleak in CServer on instant shutdown r=Jupeyy a=def- ``` Direct leak of 566869 byte(s) in 1 object(s) allocated from: #0 0x4f28e3 in __interceptor_malloc (/home/teeworlds/servers/DDNet-Server-asan+0x4f28e3) #1 0x55b3c9 in CServer::LoadMap(char const*) /home/teeworlds/src/master/src/engine/server/server.cpp:2312:49 #2 0x55bfdd in CServer::Run() /home/teeworlds/src/master/src/engine/server/server.cpp:2351:6 #3 0x56add2 in main /home/teeworlds/src/master/src/engine/server/server.cpp:3553:21 #4 0x7f54401cd09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) ``` ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [x] Considered possible null pointers and out of bounds array indexing - [x] Changed no physics that affect existing maps - [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) 3305: DemoRecorder: Only remove existing filenames r=Jupeyy a=def- As noticed by Jupstar ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [x] Considered possible null pointers and out of bounds array indexing - [x] Changed no physics that affect existing maps - [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) 3307: Don't crash with debug mode in demo r=Jupeyy a=def- Since character doesn't exist then. Reported by murpi Originally introduced in https://github.com/ddnet/ddnet/pull/2578 <!-- What is the motivation for the changes of this pull request --> ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
d80d1df0db
|
@ -3873,7 +3873,8 @@ void CClient::DemoRecorder_Stop(int Recorder, bool RemoveFile)
|
|||
if(RemoveFile)
|
||||
{
|
||||
const char *pFilename = (&m_DemoRecorder[Recorder])->GetCurrentFilename();
|
||||
Storage()->RemoveFile(pFilename, IStorage::TYPE_SAVE);
|
||||
if(pFilename[0] != '\0')
|
||||
Storage()->RemoveFile(pFilename, IStorage::TYPE_SAVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -329,6 +329,17 @@ CServer::CServer() :
|
|||
Init();
|
||||
}
|
||||
|
||||
CServer::~CServer()
|
||||
{
|
||||
for(auto &pCurrentMapData : m_apCurrentMapData)
|
||||
{
|
||||
if(pCurrentMapData)
|
||||
free(pCurrentMapData);
|
||||
}
|
||||
|
||||
delete m_pConnectionPool;
|
||||
}
|
||||
|
||||
bool CServer::IsClientNameAvailable(int ClientID, const char *pNameRequest)
|
||||
{
|
||||
// check for empty names
|
||||
|
@ -2649,11 +2660,7 @@ int CServer::Run()
|
|||
GameServer()->OnShutdown();
|
||||
m_pMap->Unload();
|
||||
|
||||
for(auto &pCurrentMapData : m_apCurrentMapData)
|
||||
free(pCurrentMapData);
|
||||
|
||||
DbPool()->OnShutdown();
|
||||
delete m_pConnectionPool;
|
||||
|
||||
#if defined(CONF_UPNP)
|
||||
m_UPnP.Shutdown();
|
||||
|
|
|
@ -257,6 +257,7 @@ public:
|
|||
array<CNameBan> m_aNameBans;
|
||||
|
||||
CServer();
|
||||
~CServer();
|
||||
|
||||
bool IsClientNameAvailable(int ClientID, const char *pNameRequest);
|
||||
bool SetClientNameImpl(int ClientID, const char *pNameRequest, bool Set);
|
||||
|
|
|
@ -481,7 +481,7 @@ public:
|
|||
|
||||
bool Success = !fs_remove(aBuffer);
|
||||
if(!Success)
|
||||
dbg_msg("storage", "failed to remove: %s", aBuffer);
|
||||
dbg_msg("storage", "failed to remove binary: %s", aBuffer);
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,11 @@ void CDebugHud::RenderNetCorrections()
|
|||
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
||||
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
||||
y += LineHeight;
|
||||
str_format(aBuf, sizeof(aBuf), "%d", m_pClient->m_GameWorld.GetCharacterByID(m_pClient->m_Snap.m_LocalClientID)->m_TeleCheckpoint);
|
||||
const CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterByID(m_pClient->m_Snap.m_LocalClientID);
|
||||
if(pCharacter)
|
||||
str_format(aBuf, sizeof(aBuf), "%d", pCharacter->m_TeleCheckpoint);
|
||||
else
|
||||
str_copy(aBuf, "-1", sizeof(aBuf));
|
||||
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
||||
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
||||
y += 2 * LineHeight;
|
||||
|
|
Loading…
Reference in a new issue