Merge branch 'cb/curl-use-xmalloc'

HTTP transport had possible allocator/deallocator mismatch, which
has been corrected.

* cb/curl-use-xmalloc:
  remote-curl: unbreak http.extraHeader with custom allocators
maint
Junio C Hamano 2019-12-01 09:04:33 -08:00
commit bad5ed39cd
1 changed files with 8 additions and 10 deletions

18
http.c
View File

@ -150,7 +150,7 @@ static unsigned long empty_auth_useless =


static struct curl_slist *pragma_header; static struct curl_slist *pragma_header;
static struct curl_slist *no_pragma_header; static struct curl_slist *no_pragma_header;
static struct curl_slist *extra_http_headers; static struct string_list extra_http_headers = STRING_LIST_INIT_DUP;


static struct active_request_slot *active_queue_head; static struct active_request_slot *active_queue_head;


@ -414,11 +414,9 @@ static int http_options(const char *var, const char *value, void *cb)
if (!value) { if (!value) {
return config_error_nonbool(var); return config_error_nonbool(var);
} else if (!*value) { } else if (!*value) {
curl_slist_free_all(extra_http_headers); string_list_clear(&extra_http_headers, 0);
extra_http_headers = NULL;
} else { } else {
extra_http_headers = string_list_append(&extra_http_headers, value);
curl_slist_append(extra_http_headers, value);
} }
return 0; return 0;
} }
@ -1202,8 +1200,7 @@ void http_cleanup(void)
#endif #endif
curl_global_cleanup(); curl_global_cleanup();


curl_slist_free_all(extra_http_headers); string_list_clear(&extra_http_headers, 0);
extra_http_headers = NULL;


curl_slist_free_all(pragma_header); curl_slist_free_all(pragma_header);
pragma_header = NULL; pragma_header = NULL;
@ -1627,10 +1624,11 @@ int run_one_slot(struct active_request_slot *slot,


struct curl_slist *http_copy_default_headers(void) struct curl_slist *http_copy_default_headers(void)
{ {
struct curl_slist *headers = NULL, *h; struct curl_slist *headers = NULL;
const struct string_list_item *item;


for (h = extra_http_headers; h; h = h->next) for_each_string_list_item(item, &extra_http_headers)
headers = curl_slist_append(headers, h->data); headers = curl_slist_append(headers, item->string);


return headers; return headers;
} }