зеркало из https://github.com/microsoft/git.git
setup_discovered_git_dir(): plug memory leak
The setup_explicit_git_dir() function does not take custody of the string passed as first parameter; we have to release it if we turned the value of git_dir into an absolute path. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
da6f847559
Коммит
2d4dcf210e
9
setup.c
9
setup.c
|
@ -703,11 +703,16 @@ static const char *setup_discovered_git_dir(const char *gitdir,
|
|||
|
||||
/* --work-tree is set without --git-dir; use discovered one */
|
||||
if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) {
|
||||
char *to_free = NULL;
|
||||
const char *ret;
|
||||
|
||||
if (offset != cwd->len && !is_absolute_path(gitdir))
|
||||
gitdir = real_pathdup(gitdir, 1);
|
||||
gitdir = to_free = real_pathdup(gitdir, 1);
|
||||
if (chdir(cwd->buf))
|
||||
die_errno("Could not come back to cwd");
|
||||
return setup_explicit_git_dir(gitdir, cwd, nongit_ok);
|
||||
ret = setup_explicit_git_dir(gitdir, cwd, nongit_ok);
|
||||
free(to_free);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* #16.2, #17.2, #20.2, #21.2, #24, #25, #28, #29 (see t1510) */
|
||||
|
|
Загрузка…
Ссылка в новой задаче