Fix a heap-use-after-free

This commit is contained in:
Learath 2017-10-17 14:23:13 +02:00
parent 648452ca60
commit 7f8356e37e
2 changed files with 9 additions and 1 deletions

View file

@ -3639,6 +3639,12 @@ void CClient::RequestDDNetInfo()
str_append(aUrl, aEscaped, sizeof(aUrl));
}
if(m_pDDNetInfoTask)
{
m_pDDNetInfoTask->Abort();
m_pDDNetInfoTask->Destroy();
}
m_pDDNetInfoTask = Fetcher()->FetchFile(aUrl, "ddnet-info.json.tmp", IStorage::TYPE_SAVE, true, true);
}

View file

@ -49,7 +49,7 @@ public:
void CFetchTask::Destroy()
{
if(m_State >= IFetchTask::STATE_DONE || m_State == IFetchTask::STATE_ERROR)
if(m_Job.Status() == CJob::STATE_DONE)
{
delete this;
}
@ -87,6 +87,8 @@ IFetchTask *CFetcher::FetchFile(const char *pUrl, const char *pDest, int Storage
pTask->m_pUser = pUser;
pTask->m_pfnCompCallback = pfnCompCb;
pTask->m_pfnProgressCallback = pfnProgCb;
pTask->m_UseDDNetCA = UseDDNetCA;
pTask->m_CanTimeout = CanTimeout;
pTask->m_Abort = false;
pTask->m_Destroy = false;