Check curl_multi_init() return value

Return NULL wxWebRequest if this function fails.

Also get rid of another unnecessary Initialize() function.
This commit is contained in:
Vadim Zeitlin
2020-12-13 17:06:15 +01:00
parent 77d25edce2
commit 76499a3e8b
2 changed files with 9 additions and 8 deletions

View File

@@ -133,8 +133,6 @@ private:
wxMutex m_cancelledMutex;
wxVector< wxObjectDataPtr<wxWebRequestCURL> > m_cancelledRequests;
void Initialize();
static int ms_activeSessions;
wxDECLARE_NO_COPY_CLASS(wxWebSessionCURL);

View File

@@ -377,15 +377,18 @@ wxWebSessionCURL::~wxWebSessionCURL()
curl_global_cleanup();
}
void wxWebSessionCURL::Initialize()
{
m_handle = curl_multi_init();
}
wxWebRequest* wxWebSessionCURL::CreateRequest(const wxString& url, int id)
{
// Allocate our handle on demand.
if ( !m_handle )
Initialize();
{
m_handle = curl_multi_init();
if ( !m_handle )
{
wxLogDebug("curl_multi_init() failed");
return NULL;
}
}
return new wxWebRequestCURL(*this, id, url);
}