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,9 @@ class HTTPRequest

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

void SetSkipCallback(bool bSkip) { m_bSkipCallback = bSkip; }


private:
void PlatformStartRequest();

Expand Down Expand Up @@ -91,10 +94,12 @@ class HTTPRequest
bool m_bNeedsProgressUpdate = false;
bool m_bIsStarted = false;
bool m_bIsComplete = false;
bool m_bSkipCallback = false;


struct curl_slist* headers = nullptr;

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 @@ -91,6 +91,8 @@ void HTTPManager::Shutdown()
HTTPRequest* pRequest = *it;
if (pRequest != nullptr && pRequest->EasyHandleMatches(pCurlHandle))
{
// Skip callback invocation during shutdown to prevent use-after-free
pRequest->SetSkipCallback(true);
pRequest->Threaded_SetComplete(m->data.result);
delete pRequest;
m_vecRequestsInFlight.erase(it);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ void HTTPRequest::InvokeCallbackIfComplete()
{
if (m_bIsComplete)
{
// Skip callback invocation if we're shutting down to avoid use-after-free
if (m_bSkipCallback)
{
return;
}

if (m_completionCallback != nullptr)
{
// Convert m_vecBuffer to std::string for m_strResponse
Expand Down
Loading