Skip to content

Commit 11ea82a

Browse files
committed
Merge branch 'rs/remote-mv-leakfix'
Leakfix. * rs/remote-mv-leakfix: remote: clear string_list after use in mv()
2 parents c5c26f7 + fe583c6 commit 11ea82a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

builtin/remote.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static int read_remote_branches(const char *refname,
566566

567567
strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name);
568568
if (starts_with(refname, buf.buf)) {
569-
item = string_list_append(rename->remote_branches, xstrdup(refname));
569+
item = string_list_append(rename->remote_branches, refname);
570570
symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
571571
NULL, &flag);
572572
if (symref && (flag & REF_ISSYMREF))
@@ -612,7 +612,7 @@ static int mv(int argc, const char **argv)
612612
struct remote *oldremote, *newremote;
613613
struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT, buf3 = STRBUF_INIT,
614614
old_remote_context = STRBUF_INIT;
615-
struct string_list remote_branches = STRING_LIST_INIT_NODUP;
615+
struct string_list remote_branches = STRING_LIST_INIT_DUP;
616616
struct rename_info rename;
617617
int i, refspec_updated = 0;
618618

@@ -734,6 +734,7 @@ static int mv(int argc, const char **argv)
734734
if (create_symref(buf.buf, buf2.buf, buf3.buf))
735735
die(_("creating '%s' failed"), buf.buf);
736736
}
737+
string_list_clear(&remote_branches, 1);
737738
return 0;
738739
}
739740

0 commit comments

Comments
 (0)