show_worktree(): plug memory leak
The buffer allocated by shorten_unambiguous_ref() needs to be released. Discovered by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
5308224633
commit
2e11f58fa6
|
@ -414,9 +414,11 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)
|
||||||
find_unique_abbrev(wt->head_sha1, DEFAULT_ABBREV));
|
find_unique_abbrev(wt->head_sha1, DEFAULT_ABBREV));
|
||||||
if (wt->is_detached)
|
if (wt->is_detached)
|
||||||
strbuf_addstr(&sb, "(detached HEAD)");
|
strbuf_addstr(&sb, "(detached HEAD)");
|
||||||
else if (wt->head_ref)
|
else if (wt->head_ref) {
|
||||||
strbuf_addf(&sb, "[%s]", shorten_unambiguous_ref(wt->head_ref, 0));
|
char *ref = shorten_unambiguous_ref(wt->head_ref, 0);
|
||||||
else
|
strbuf_addf(&sb, "[%s]", ref);
|
||||||
|
free(ref);
|
||||||
|
} else
|
||||||
strbuf_addstr(&sb, "(error)");
|
strbuf_addstr(&sb, "(error)");
|
||||||
}
|
}
|
||||||
printf("%s\n", sb.buf);
|
printf("%s\n", sb.buf);
|
||||||
|
|
Loading…
Reference in New Issue