clone: use free() instead of UNLEAK()
Change an UNLEAK() added in 0c4542738e
(clone: free or UNLEAK further
pointers when finished, 2021-03-14) to use a "to_free" pattern
instead. In this case the "repo" can be either this absolute_pathdup()
value, or in the "else if" branch seen in the context the the
"argv[0]" argument to "main()".
We can only free() the value in the former case, hence the "to_free"
pattern.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e8ed0a8ac5
commit
81e5c39cf6
@ -892,6 +892,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
|||||||
int is_bundle = 0, is_local;
|
int is_bundle = 0, is_local;
|
||||||
int reject_shallow = 0;
|
int reject_shallow = 0;
|
||||||
const char *repo_name, *repo, *work_tree, *git_dir;
|
const char *repo_name, *repo, *work_tree, *git_dir;
|
||||||
|
char *repo_to_free = NULL;
|
||||||
char *path = NULL, *dir, *display_repo = NULL;
|
char *path = NULL, *dir, *display_repo = NULL;
|
||||||
int dest_exists, real_dest_exists = 0;
|
int dest_exists, real_dest_exists = 0;
|
||||||
const struct ref *refs, *remote_head;
|
const struct ref *refs, *remote_head;
|
||||||
@ -949,7 +950,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
|||||||
path = get_repo_path(repo_name, &is_bundle);
|
path = get_repo_path(repo_name, &is_bundle);
|
||||||
if (path) {
|
if (path) {
|
||||||
FREE_AND_NULL(path);
|
FREE_AND_NULL(path);
|
||||||
repo = absolute_pathdup(repo_name);
|
repo = repo_to_free = absolute_pathdup(repo_name);
|
||||||
} else if (strchr(repo_name, ':')) {
|
} else if (strchr(repo_name, ':')) {
|
||||||
repo = repo_name;
|
repo = repo_name;
|
||||||
display_repo = transport_anonymize_url(repo);
|
display_repo = transport_anonymize_url(repo);
|
||||||
@ -1413,7 +1414,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
|||||||
free(unborn_head);
|
free(unborn_head);
|
||||||
free(dir);
|
free(dir);
|
||||||
free(path);
|
free(path);
|
||||||
UNLEAK(repo);
|
free(repo_to_free);
|
||||||
junk_mode = JUNK_LEAVE_ALL;
|
junk_mode = JUNK_LEAVE_ALL;
|
||||||
|
|
||||||
transport_ls_refs_options_release(&transport_ls_refs_options);
|
transport_ls_refs_options_release(&transport_ls_refs_options);
|
||||||
|
Loading…
Reference in New Issue
Block a user