summaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-08-27 14:04:49 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-08-27 14:04:49 -0700
commit0d9a8e33f9fd07efa10072576df01a9cae5d89e6 (patch)
tree5a01c05bf4d8e6d775c4843e5c760e81be4a780b /builtin/checkout.c
parentMerge branch 'en/mem-pool' (diff)
parentsubmodule--helper: fix leak of core.worktree value (diff)
downloadtgif-0d9a8e33f9fd07efa10072576df01a9cae5d89e6.tar.xz
Merge branch 'jk/leakfix'
Code clean-up. * jk/leakfix: submodule--helper: fix leak of core.worktree value config: fix leak in git_config_get_expiry_in_days() config: drop git_config_get_string_const() config: fix leaks from git_config_get_string_const() checkout: fix leak of non-existent branch names submodule--helper: use strbuf_release() to free strbufs clear_pattern_list(): clear embedded hashmaps
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2837195491..bba64108af 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1120,8 +1120,10 @@ static void setup_new_branch_info_and_source_tree(
if (!check_refname_format(new_branch_info->path, 0) &&
!read_ref(new_branch_info->path, &branch_rev))
oidcpy(rev, &branch_rev);
- else
+ else {
+ free((char *)new_branch_info->path);
new_branch_info->path = NULL; /* not an existing branch */
+ }
new_branch_info->commit = lookup_commit_reference_gently(the_repository, rev, 1);
if (!new_branch_info->commit) {