diff options
| author | Junio C Hamano <gitster@pobox.com> | 2021-04-07 16:54:08 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-04-07 16:54:08 -0700 |
| commit | 642a40019c99a42f5f4ed4f3e52b9ab92cd75fe7 (patch) | |
| tree | 03da4a9395b7d4eda1517fb783e246cfeb80c965 /builtin/worktree.c | |
| parent | The sixth batch (diff) | |
| parent | transport: also free remote_refs in transport_disconnect() (diff) | |
| download | git-642a40019c99a42f5f4ed4f3e52b9ab92cd75fe7.tar.gz git-642a40019c99a42f5f4ed4f3e52b9ab92cd75fe7.zip | |
Merge branch 'ah/plugleaks'
Plug or annotate remaining leaks that trigger while running the
very basic set of tests.
* ah/plugleaks:
transport: also free remote_refs in transport_disconnect()
parse-options: don't leak alias help messages
parse-options: convert bitfield values to use binary shift
init-db: silence template_dir leak when converting to absolute path
init: remove git_init_db_config() while fixing leaks
worktree: fix leak in dwim_branch()
clone: free or UNLEAK further pointers when finished
reset: free instead of leaking unneeded ref
symbolic-ref: don't leak shortened refname in check_symref()
Diffstat (limited to 'builtin/worktree.c')
| -rw-r--r-- | builtin/worktree.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c index 1cd5c2016e..8771453493 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -446,16 +446,18 @@ static void print_preparing_worktree_line(int detach, static const char *dwim_branch(const char *path, const char **new_branch) { int n; + int branch_exists; const char *s = worktree_basename(path, &n); const char *branchname = xstrndup(s, n); struct strbuf ref = STRBUF_INIT; UNLEAK(branchname); - if (!strbuf_check_branch_ref(&ref, branchname) && - ref_exists(ref.buf)) { - strbuf_release(&ref); + + branch_exists = !strbuf_check_branch_ref(&ref, branchname) && + ref_exists(ref.buf); + strbuf_release(&ref); + if (branch_exists) return branchname; - } *new_branch = branchname; if (guess_remote) { |
