diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-05-29 12:34:44 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-29 12:34:44 +0900 |
commit | 849e671b52e11d4a2f70d577dd2c806f3ca756fe (patch) | |
tree | f564d4d2782856efcdcff278b385a989c031a6c1 /builtin/worktree.c | |
parent | Merge branch 'jk/disable-pack-reuse-when-broken' (diff) | |
parent | checkout: fix memory leak (diff) | |
download | tgif-849e671b52e11d4a2f70d577dd2c806f3ca756fe.tar.xz |
Merge branch 'js/plug-leaks'
Fix memory leaks pointed out by Coverity (and people).
* js/plug-leaks: (26 commits)
checkout: fix memory leak
submodule_uses_worktrees(): plug memory leak
show_worktree(): plug memory leak
name-rev: avoid leaking memory in the `deref` case
remote: plug memory leak in match_explicit()
add_reflog_for_walk: avoid memory leak
shallow: avoid memory leak
line-log: avoid memory leak
receive-pack: plug memory leak in update()
fast-export: avoid leaking memory in handle_tag()
mktree: plug memory leaks reported by Coverity
pack-redundant: plug memory leak
setup_discovered_git_dir(): plug memory leak
setup_bare_git_dir(): help static analysis
split_commit_in_progress(): simplify & fix memory leak
checkout: fix memory leak
cat-file: fix memory leak
mailinfo & mailsplit: check for EOF while parsing
status: close file descriptor after reading git-rebase-todo
difftool: address a couple of resource/memory leaks
...
Diffstat (limited to 'builtin/worktree.c')
-rw-r--r-- | builtin/worktree.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c index 11f90d6e45..793306ea51 100644 --- 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); |