mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix memleak of multiply chained console commands
This commit is contained in:
parent
898259fe6c
commit
177cdfdde9
|
@ -991,8 +991,18 @@ CConsole::~CConsole()
|
||||||
while(pCommand)
|
while(pCommand)
|
||||||
{
|
{
|
||||||
CCommand *pNext = pCommand->m_pNext;
|
CCommand *pNext = pCommand->m_pNext;
|
||||||
if(pCommand->m_pfnCallback == Con_Chain)
|
{
|
||||||
delete static_cast<CChain *>(pCommand->m_pUserData);
|
FCommandCallback pfnCallback = pCommand->m_pfnCallback;
|
||||||
|
void *pUserData = pCommand->m_pUserData;
|
||||||
|
CChain *pChain = nullptr;
|
||||||
|
while(pfnCallback == Con_Chain)
|
||||||
|
{
|
||||||
|
pChain = static_cast<CChain *>(pUserData);
|
||||||
|
pfnCallback = pChain->m_pfnCallback;
|
||||||
|
pUserData = pChain->m_pCallbackUserData;
|
||||||
|
delete pChain;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Temp commands are on m_TempCommands heap, so don't delete them
|
// Temp commands are on m_TempCommands heap, so don't delete them
|
||||||
if(!pCommand->m_Temp)
|
if(!pCommand->m_Temp)
|
||||||
delete pCommand;
|
delete pCommand;
|
||||||
|
|
Loading…
Reference in a new issue