File tree Expand file tree Collapse file tree
GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline/HTTP Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,7 +103,12 @@ void HTTPManager::Shutdown()
103103 HTTPRequest* pRequest = *it;
104104 if (pRequest != nullptr && pRequest->EasyHandleMatches (pCurlHandle))
105105 {
106- pRequest->Threaded_SetComplete (m->data .result );
106+ // During shutdown, skip invoking the completion callback. The callback
107+ // may reference objects (e.g. NGMP_OnlineServices_StatsInterface via
108+ // captured 'this') that have already been or are being destroyed,
109+ // leading to use-after-free memory corruption and crashes in unrelated
110+ // destructors such as GameSpyMiscPreferences::~GameSpyMiscPreferences().
111+ // HTTPRequest::~HTTPRequest() handles all necessary curl handle cleanup.
107112 delete pRequest;
108113 m_vecRequestsInFlight.erase (it);
109114 break ;
@@ -122,6 +127,17 @@ void HTTPManager::Shutdown()
122127
123128 NetworkLog (ELogVerbosity::LOG_RELEASE, " [HTTPManager] All in-flight requests completed" );
124129
130+ // Delete any remaining in-flight requests without invoking their callbacks.
131+ // These are requests that completed via curl but were not matched above, or
132+ // requests that are still pending completion. Invoking callbacks here is unsafe
133+ // as the objects they reference may already be destroyed.
134+ for (HTTPRequest* pRequest : m_vecRequestsInFlight)
135+ {
136+ if (pRequest != nullptr )
137+ {
138+ delete pRequest;
139+ }
140+ }
125141 m_vecRequestsInFlight.clear ();
126142
127143 // Now safe to cleanup
You can’t perform that action at this time.
0 commit comments