Keep http header of curl_slist* until the exit of stk to prevent memory leak
This commit is contained in:
parent
dd15947aa1
commit
612e8bdaf6
@ -31,6 +31,7 @@
|
||||
namespace Online
|
||||
{
|
||||
std::string HTTPRequest::m_cert_location;
|
||||
struct curl_slist* HTTPRequest::m_http_header = NULL;
|
||||
const std::string API::USER_PATH = "user/";
|
||||
const std::string API::SERVER_PATH = "server/";
|
||||
|
||||
@ -100,6 +101,11 @@ namespace Online
|
||||
m_cert_location =
|
||||
file_manager->getAsset("addons.supertuxkart.net.pem");
|
||||
}
|
||||
if (m_http_header == NULL)
|
||||
{
|
||||
m_http_header = curl_slist_append(m_http_header,
|
||||
"Host: addons.supertuxkart.net");
|
||||
}
|
||||
m_disable_sending_log = false;
|
||||
} // init
|
||||
|
||||
@ -182,9 +188,9 @@ namespace Online
|
||||
if (m_url.substr(0, 8) == "https://")
|
||||
{
|
||||
// https, load certificate info
|
||||
struct curl_slist *chunk = NULL;
|
||||
chunk = curl_slist_append(chunk, "Host: addons.supertuxkart.net");
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER, chunk);
|
||||
assert(m_http_header != NULL);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER,
|
||||
m_http_header);
|
||||
CURLcode error = curl_easy_setopt(m_curl_session, CURLOPT_CAINFO,
|
||||
m_cert_location.c_str());
|
||||
if (error != CURLE_OK)
|
||||
|
@ -72,6 +72,8 @@ namespace Online
|
||||
std::string m_string_buffer;
|
||||
|
||||
static std::string m_cert_location;
|
||||
|
||||
static struct curl_slist* m_http_header;
|
||||
protected:
|
||||
bool m_disable_sending_log;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user