Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
show_worktree(): plug memory leak
author
Johannes Schindelin
<johannes.schindelin@gmx.de>
Thu, 4 May 2017 13:59:13 +0000
(15:59 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 8 May 2017 03:18:20 +0000
(12:18 +0900)
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>
builtin/worktree.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
5308224
)
diff --git
a/builtin/worktree.c
b/builtin/worktree.c
index 1722a9bdc2a07ce3d98921299c6b57d03a50e870..ff5dfd2b1022fd94314f2cefe3ca91a4820e8abf 100644
(file)
--- a/
builtin/worktree.c
+++ b/
builtin/worktree.c
@@
-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));
if (wt->is_detached)
strbuf_addstr(&sb, "(detached HEAD)");
- else if (wt->head_ref)
- strbuf_addf(&sb, "[%s]", shorten_unambiguous_ref(wt->head_ref, 0));
- else
+ else if (wt->head_ref) {
+ char *ref = shorten_unambiguous_ref(wt->head_ref, 0);
+ strbuf_addf(&sb, "[%s]", ref);
+ free(ref);
+ } else
strbuf_addstr(&sb, "(error)");
}
printf("%s\n", sb.buf);