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 @@ -398,6 +398,15 @@ class NGMP_OnlineServicesManager

~NGMP_OnlineServicesManager()
{
// IMPORTANT: Delete HTTPManager BEFORE deleting interface objects
// HTTPManager::Shutdown() will invoke completion callbacks, which may reference interface objects
// We must ensure interfaces are still valid when callbacks execute
if (m_pHTTPManager != nullptr)
{
delete m_pHTTPManager;
m_pHTTPManager = nullptr;
}

if (m_pAuthInterface != nullptr)
{
delete m_pAuthInterface;
Expand All @@ -422,12 +431,6 @@ class NGMP_OnlineServicesManager
m_pRoomInterface = nullptr;
}

if (m_pHTTPManager != nullptr)
{
delete m_pHTTPManager;
m_pHTTPManager = nullptr;
}

// Reset shared_ptr, which will delete WebSocket only when all references are released
m_pWebSocket.reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ void HTTPRequest::InvokeCallbackIfComplete()
{
strResponse.clear();
}

// Invoke the callback
m_completionCallback(true, m_responseCode, strResponse, this);

// Clear the callback immediately after invocation to prevent use-after-free
// during std::function cleanup, especially during shutdown scenarios
m_completionCallback = nullptr;
}
}
}
Expand Down
Loading