aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-08-14 14:54:49 -0700
committerJunio C Hamano <gitster@pobox.com>2024-08-14 14:54:49 -0700
commitecbed3ff4597023f044f097c8da7f43a9228a5e1 (patch)
tree69ce0a3c6f26105935dec4a51ab4f759a3ef0939
parent4bad0119f2b2f1b85a3b3d1575e097c37b1230d8 (diff)
parent448d51d549179bafe47e07e9434210d48fdf55c6 (diff)
downloadgit-ecbed3ff4597023f044f097c8da7f43a9228a5e1.tar.gz
Merge branch 'jc/transport-leakfix'
Leakfix. * jc/transport-leakfix: transport: fix leak with transport helper URLs
-rw-r--r--transport.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/transport.c b/transport.c
index 12cc5b4d96..7c4af9f56f 100644
--- a/transport.c
+++ b/transport.c
@@ -1115,6 +1115,7 @@ static struct transport_vtable builtin_smart_vtable = {
struct transport *transport_get(struct remote *remote, const char *url)
{
const char *helper;
+ char *helper_to_free = NULL;
const char *p;
struct transport *ret = xcalloc(1, sizeof(*ret));
@@ -1139,10 +1140,11 @@ struct transport *transport_get(struct remote *remote, const char *url)
while (is_urlschemechar(p == url, *p))
p++;
if (starts_with(p, "::"))
- helper = xstrndup(url, p - url);
+ helper = helper_to_free = xstrndup(url, p - url);
if (helper) {
transport_helper_init(ret, helper);
+ free(helper_to_free);
} else if (starts_with(url, "rsync:")) {
die(_("git-over-rsync is no longer supported"));
} else if (url_is_local_not_ssh(url) && is_file(url) && is_bundle(url, 1)) {