mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #2096
2096: Fix the double-free of the antibot r=def- a=heinrich5991 I could not find an easy way to ensure that `AntibotDestroy` is only being called once for each `AntibotInit` but still happening after all the `CPlayer` destructors. Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
This commit is contained in:
commit
fb81000351
|
@ -25,6 +25,15 @@ CAntibot::CAntibot()
|
|||
}
|
||||
CAntibot::~CAntibot()
|
||||
{
|
||||
// Check if `Init` was called. There is no easy way to prevent two
|
||||
// destructors running without an `Init` call in between.
|
||||
if(m_pGameContext)
|
||||
{
|
||||
AntibotDestroy();
|
||||
free(g_Data.m_Map.m_pTiles);
|
||||
g_Data.m_Map.m_pTiles = 0;
|
||||
m_pGameContext = 0;
|
||||
}
|
||||
}
|
||||
void CAntibot::Init(CGameContext *pGameContext)
|
||||
{
|
||||
|
@ -37,12 +46,6 @@ void CAntibot::Init(CGameContext *pGameContext)
|
|||
AntibotInit(&g_Data);
|
||||
Update();
|
||||
}
|
||||
void CAntibot::Shutdown()
|
||||
{
|
||||
AntibotDestroy();
|
||||
free(g_Data.m_Map.m_pTiles);
|
||||
g_Data.m_Map.m_pTiles = 0;
|
||||
}
|
||||
void CAntibot::Dump() { AntibotDump(); }
|
||||
void CAntibot::Update()
|
||||
{
|
||||
|
@ -75,9 +78,6 @@ void CAntibot::Dump()
|
|||
{
|
||||
m_pGameContext->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "antibot", "antibot support not compiled in");
|
||||
}
|
||||
void CAntibot::Shutdown()
|
||||
{
|
||||
}
|
||||
void CAntibot::Update()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ public:
|
|||
CAntibot();
|
||||
~CAntibot();
|
||||
void Init(CGameContext *pGameContext);
|
||||
void Shutdown();
|
||||
void Dump();
|
||||
|
||||
void OnPlayerInit(int ClientID);
|
||||
|
|
|
@ -3044,8 +3044,6 @@ void CGameContext::OnShutdown(bool FullShutdown)
|
|||
if (FullShutdown)
|
||||
Score()->OnShutdown();
|
||||
|
||||
m_Antibot.Shutdown();
|
||||
|
||||
if(m_TeeHistorianActive)
|
||||
{
|
||||
m_TeeHistorian.Finish();
|
||||
|
|
Loading…
Reference in a new issue