summaryrefslogtreecommitdiff
path: root/builtin/remote.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2018-08-01 10:19:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-01 16:55:09 (GMT)
commitfe583c6c7a6726452aac87a14afa5a0bf9647d8f (patch)
tree8b876c031cdba01f2e2aad41235fce1e724bbc2c /builtin/remote.c
parent53f9a3e157dbbc901a02ac2c73346d375e24978c (diff)
downloadgit-fe583c6c7a6726452aac87a14afa5a0bf9647d8f.zip
git-fe583c6c7a6726452aac87a14afa5a0bf9647d8f.tar.gz
git-fe583c6c7a6726452aac87a14afa5a0bf9647d8f.tar.bz2
remote: clear string_list after use in mv()
Switch to the _DUP variant of string_list for remote_branches to allow string_list_clear() to release the allocated memory at the end, and actually call that function. Free the util pointer as well; it is allocated in read_remote_branches(). NB: This string_list is empty until read_remote_branches() is called via for_each_ref(), so there is no need to clean it up when returning before that point. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/remote.c')
-rw-r--r--builtin/remote.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index 1a82d85..213c07b 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -565,7 +565,7 @@ static int read_remote_branches(const char *refname,
strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name);
if (starts_with(refname, buf.buf)) {
- item = string_list_append(rename->remote_branches, xstrdup(refname));
+ item = string_list_append(rename->remote_branches, refname);
symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
NULL, &flag);
if (symref && (flag & REF_ISSYMREF))
@@ -611,7 +611,7 @@ static int mv(int argc, const char **argv)
struct remote *oldremote, *newremote;
struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT, buf3 = STRBUF_INIT,
old_remote_context = STRBUF_INIT;
- struct string_list remote_branches = STRING_LIST_INIT_NODUP;
+ struct string_list remote_branches = STRING_LIST_INIT_DUP;
struct rename_info rename;
int i, refspec_updated = 0;
@@ -733,6 +733,7 @@ static int mv(int argc, const char **argv)
if (create_symref(buf.buf, buf2.buf, buf3.buf))
die(_("creating '%s' failed"), buf.buf);
}
+ string_list_clear(&remote_branches, 1);
return 0;
}