Add cleanup for cURL header slist

This commit is contained in:
Joshua Granick
2018-03-20 14:21:14 -07:00
parent 6eb9a3cd0d
commit e2499abaab

View File

@@ -11,6 +11,7 @@ namespace lime {
std::map<value, bool> curlValid;
std::map<value, AutoGCRoot*> headerCallbacks;
std::map<value, curl_slist*> headerSLists;
std::map<value, AutoGCRoot*> progressCallbacks;
std::map<value, AutoGCRoot*> readCallbacks;
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 ()) {
callback = progressCallbacks[handle];
@@ -732,6 +741,12 @@ namespace lime {
case CURLOPT_HTTPHEADER:
{
if (headerSLists.find (handle) != headerSLists.end ()) {
curl_slist_free_all (headerSLists[handle]);
}
struct curl_slist *chunk = NULL;
int size = val_array_size (parameter);
@@ -741,6 +756,8 @@ namespace lime {
}
headerSLists[handle] = chunk;
code = curl_easy_setopt (curl, type, chunk);
break;
}