Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ class HTTPRequest

std::string GetURI() { return m_strURI; }

// Clear callbacks to prevent use-after-free during shutdown
void ClearCallbacks()
{
m_completionCallback = nullptr;
m_progressCallback = nullptr;
}


private:
void PlatformStartRequest();

Expand Down Expand Up @@ -97,4 +105,4 @@ class HTTPRequest
std::function<void(bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)> m_completionCallback = nullptr;

std::function<void(size_t bytesReceived)> m_progressCallback = nullptr;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ void HTTPManager::Shutdown()

NetworkLog(ELogVerbosity::LOG_RELEASE, "[HTTPManager] Waiting for %d in-flight requests to complete...", (int)m_vecRequestsInFlight.size());

// Clear all callbacks on in-flight requests to prevent use-after-free
// when callbacks are invoked during shutdown with dangling pointers
for (HTTPRequest* pRequest : m_vecRequestsInFlight)
{
if (pRequest != nullptr)
{
pRequest->ClearCallbacks();
}
}

// Wait for all in-flight requests to complete
if (m_pCurl != nullptr)
{
Expand Down
Loading