Skip to content
Browse files
remote-curl: unbreak http.extraHeader with custom allocators
In 93b980e (http: use xmalloc with cURL, 2019-08-15), we started to
ask cURL to use `xmalloc()`, and if compiled with nedmalloc, that means
implicitly a different allocator than the system one.

Which means that all of cURL's allocations and releases now _need_ to
use that allocator.

However, the `http_options()` function used `slist_append()` to add any
configured extra HTTP header(s) _before_ asking cURL to use `xmalloc()`,
and `http_cleanup()` would release them _afterwards_, i.e. in the
presence of custom allocators, cURL would attempt to use the wrong
allocator to release the memory.

Let's fix this by moving the initialization _before_ the
`http_options()` function is called.

Signed-off-by: Johannes Schindelin <>
  • Loading branch information
dscho committed Nov 4, 2019
1 parent 6a3fa2a commit b330925f35f62081ca616a4f5787034bc3391676
Showing with 3 additions and 3 deletions.
  1. +3 −3 http.c
6 http.c
@@ -1064,6 +1064,9 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
char *normalized_url;
struct urlmatch_config config = { STRING_LIST_INIT_DUP };

if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
die("curl_global_init failed");

config.section = "http";
config.key = NULL;
config.collect_fn = http_options;
@@ -1104,9 +1107,6 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)

if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
die("curl_global_init failed");

http_proactive_auth = proactive_auth;

if (remote && remote->http_proxy)

0 comments on commit b330925

Please sign in to comment.