Skip to content

Commit b330925

Browse files
committed
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 <[email protected]>
1 parent 6a3fa2a commit b330925

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

http.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,9 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
10641064
char *normalized_url;
10651065
struct urlmatch_config config = { STRING_LIST_INIT_DUP };
10661066

1067+
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
1068+
die("curl_global_init failed");
1069+
10671070
config.section = "http";
10681071
config.key = NULL;
10691072
config.collect_fn = http_options;
@@ -1104,9 +1107,6 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
11041107
}
11051108
#endif
11061109

1107-
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
1108-
die("curl_global_init failed");
1109-
11101110
http_proactive_auth = proactive_auth;
11111111

11121112
if (remote && remote->http_proxy)

0 commit comments

Comments
 (0)