Skip to content

Commit 2f50bab

Browse files
stefanbellergitster
authored andcommitted
remote.c: don't leak the base branch name in format_tracking_info
Found by scan.coverity.com (Id: 1127809) Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 32f5660 commit 2f50bab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

remote.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
19251925
int format_tracking_info(struct branch *branch, struct strbuf *sb)
19261926
{
19271927
int ours, theirs;
1928-
const char *base;
1928+
char *base;
19291929
int upstream_is_gone = 0;
19301930

19311931
switch (stat_tracking_info(branch, &ours, &theirs)) {
@@ -1941,8 +1941,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
19411941
break;
19421942
}
19431943

1944-
base = branch->merge[0]->dst;
1945-
base = shorten_unambiguous_ref(base, 0);
1944+
base = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
19461945
if (upstream_is_gone) {
19471946
strbuf_addf(sb,
19481947
_("Your branch is based on '%s', but the upstream is gone.\n"),
@@ -1988,6 +1987,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
19881987
strbuf_addf(sb,
19891988
_(" (use \"git pull\" to merge the remote branch into yours)\n"));
19901989
}
1990+
free(base);
19911991
return 1;
19921992
}
19931993

0 commit comments

Comments
 (0)