summaryrefslogtreecommitdiff
path: root/transport-helper.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-12-08 17:29:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-12-08 20:18:09 (GMT)
commit176cb979fe7c1cf6b789c9263ca20312385c1f31 (patch)
tree31ce4c26b4225debedd84df40a3b21c916e3408a /transport-helper.c
parent3013dff8662eae06457fe6e5348dfe2270810ab2 (diff)
downloadgit-176cb979fe7c1cf6b789c9263ca20312385c1f31.zip
git-176cb979fe7c1cf6b789c9263ca20312385c1f31.tar.gz
git-176cb979fe7c1cf6b789c9263ca20312385c1f31.tar.bz2
transport-helper: plug strbuf and string_list leaks
Transfer ownership of detached strbufs to string_lists of the duplicating variety by calling string_list_append_nodup() instead of string_list_append() to avoid duplicating and then leaking the buffer. While at it make sure to release the string_list when done; push_refs_with_export() already does that. Reported-by: Jeff King <peff@peff.net> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport-helper.c')
-rw-r--r--transport-helper.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/transport-helper.c b/transport-helper.c
index c948d52..3bbc105 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -881,7 +881,8 @@ static int push_refs_with_push(struct transport *transport,
struct strbuf cas = STRBUF_INIT;
strbuf_addf(&cas, "%s:%s",
ref->name, oid_to_hex(&ref->old_oid_expect));
- string_list_append(&cas_options, strbuf_detach(&cas, NULL));
+ string_list_append_nodup(&cas_options,
+ strbuf_detach(&cas, NULL));
}
}
if (buf.len == 0) {
@@ -896,6 +897,7 @@ static int push_refs_with_push(struct transport *transport,
strbuf_addch(&buf, '\n');
sendline(data, &buf);
strbuf_release(&buf);
+ string_list_clear(&cas_options, 0);
return push_update_refs_status(data, remote_refs, flags);
}
@@ -929,7 +931,8 @@ static int push_refs_with_export(struct transport *transport,
private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
if (private && !get_oid(private, &oid)) {
strbuf_addf(&buf, "^%s", private);
- string_list_append(&revlist_args, strbuf_detach(&buf, NULL));
+ string_list_append_nodup(&revlist_args,
+ strbuf_detach(&buf, NULL));
oidcpy(&ref->old_oid, &oid);
}
free(private);