Skip to content

Commit 27fbcf8

Browse files
committed
Merge branch 'sb/plug-leaks'
* sb/plug-leaks: clone.c: don't leak memory in cmd_clone remote.c: don't leak the base branch name in format_tracking_info
2 parents a75e759 + 50b6773 commit 27fbcf8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

builtin/clone.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,5 +1004,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
10041004
strbuf_release(&key);
10051005
strbuf_release(&value);
10061006
junk_mode = JUNK_LEAVE_ALL;
1007+
1008+
free(refspec);
10071009
return err;
10081010
}

remote.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
19491949
int format_tracking_info(struct branch *branch, struct strbuf *sb)
19501950
{
19511951
int ours, theirs;
1952-
const char *base;
1952+
char *base;
19531953
int upstream_is_gone = 0;
19541954

19551955
switch (stat_tracking_info(branch, &ours, &theirs)) {
@@ -1965,8 +1965,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
19651965
break;
19661966
}
19671967

1968-
base = branch->merge[0]->dst;
1969-
base = shorten_unambiguous_ref(base, 0);
1968+
base = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
19701969
if (upstream_is_gone) {
19711970
strbuf_addf(sb,
19721971
_("Your branch is based on '%s', but the upstream is gone.\n"),
@@ -2012,6 +2011,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
20122011
strbuf_addf(sb,
20132012
_(" (use \"git pull\" to merge the remote branch into yours)\n"));
20142013
}
2014+
free(base);
20152015
return 1;
20162016
}
20172017

0 commit comments

Comments
 (0)