Add cleanup for cURL header slist
This commit is contained in:
@@ -11,6 +11,7 @@ namespace lime {
|
|||||||
|
|
||||||
std::map<value, bool> curlValid;
|
std::map<value, bool> curlValid;
|
||||||
std::map<value, AutoGCRoot*> headerCallbacks;
|
std::map<value, AutoGCRoot*> headerCallbacks;
|
||||||
|
std::map<value, curl_slist*> headerSLists;
|
||||||
std::map<value, AutoGCRoot*> progressCallbacks;
|
std::map<value, AutoGCRoot*> progressCallbacks;
|
||||||
std::map<value, AutoGCRoot*> readCallbacks;
|
std::map<value, AutoGCRoot*> readCallbacks;
|
||||||
std::map<AutoGCRoot*, Bytes*> writeBytes;
|
std::map<AutoGCRoot*, Bytes*> writeBytes;
|
||||||
@@ -52,6 +53,14 @@ namespace lime {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (headerSLists.find (handle) != headerSLists.end ()) {
|
||||||
|
|
||||||
|
curl_slist* chunk = headerSLists[handle];
|
||||||
|
headerSLists.erase (handle);
|
||||||
|
curl_slist_free_all (chunk);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (progressCallbacks.find (handle) != progressCallbacks.end ()) {
|
if (progressCallbacks.find (handle) != progressCallbacks.end ()) {
|
||||||
|
|
||||||
callback = progressCallbacks[handle];
|
callback = progressCallbacks[handle];
|
||||||
@@ -732,6 +741,12 @@ namespace lime {
|
|||||||
|
|
||||||
case CURLOPT_HTTPHEADER:
|
case CURLOPT_HTTPHEADER:
|
||||||
{
|
{
|
||||||
|
if (headerSLists.find (handle) != headerSLists.end ()) {
|
||||||
|
|
||||||
|
curl_slist_free_all (headerSLists[handle]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
struct curl_slist *chunk = NULL;
|
struct curl_slist *chunk = NULL;
|
||||||
int size = val_array_size (parameter);
|
int size = val_array_size (parameter);
|
||||||
|
|
||||||
@@ -741,6 +756,8 @@ namespace lime {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
headerSLists[handle] = chunk;
|
||||||
|
|
||||||
code = curl_easy_setopt (curl, type, chunk);
|
code = curl_easy_setopt (curl, type, chunk);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user