All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>,
	"Johannes Schindelin" <johannes.schindelin@gmx.de>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Johannes Schindelin" <johannes.schindelin@gmx.de>
Subject: [PATCH 1/1] remote-curl: unbreak http.extraHeader with custom allocators
Date: Tue, 05 Nov 2019 21:59:18 +0000	[thread overview]
Message-ID: <d47a2aa5949a5dd3a10b89d9a77ebb89af6ba57e.1572991158.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.453.git.1572991158.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

In 93b980e58f5 (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 <johannes.schindelin@gmx.de>
---
 http.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/http.c b/http.c
index 27aa0a3192..13f50ba158 100644
--- a/http.c
+++ b/http.c
@@ -1062,6 +1062,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;
@@ -1101,9 +1104,6 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
 	}
 #endif
 
-	if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
-		die("curl_global_init failed");
-
 	http_proactive_auth = proactive_auth;
 
 	if (remote && remote->http_proxy)
-- 
gitgitgadget

  reply	other threads:[~2019-11-05 21:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 21:59 [PATCH 0/1] remote-curl: unbreak http.extraHeader with custom allocators Johannes Schindelin via GitGitGadget
2019-11-05 21:59 ` Johannes Schindelin via GitGitGadget [this message]
2019-11-06  4:16   ` [PATCH 1/1] " Jeff King
2019-11-06  9:14     ` Johannes Schindelin
2019-11-06  9:49       ` Junio C Hamano
2019-11-06 19:38         ` Johannes Schindelin
2019-11-08  8:34           ` Junio C Hamano
2019-11-08 13:44             ` Johannes Schindelin
2019-11-06 10:04 ` [PATCH v2 0/1] " Johannes Schindelin via GitGitGadget
2019-11-06 10:04   ` [PATCH v2 1/1] " Johannes Schindelin via GitGitGadget
2019-11-06 11:29     ` Jeff King
2019-11-06 12:12     ` Junio C Hamano
2019-11-06 19:34       ` Johannes Schindelin
2019-11-07  5:39         ` Junio C Hamano
2019-11-07 12:40           ` Johannes Schindelin
2019-11-08  3:03             ` Junio C Hamano
2019-11-06 12:15   ` [PATCH v2 0/1] " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d47a2aa5949a5dd3a10b89d9a77ebb89af6ba57e.1572991158.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.