mirror of
https://github.com/git/git.git
synced 2026-01-27 02:48:32 +00:00
setup_bare_git_dir(): help static analysis
Coverity reported a memory leak in this function. However, it can only be called once, as setup_git_directory() changes global state and hence is not reentrant. Mark the variable as static to indicate that this is a singleton. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
2
setup.c
2
setup.c
@@ -748,7 +748,7 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
|
||||
|
||||
/* --work-tree is set without --git-dir; use discovered one */
|
||||
if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) {
|
||||
const char *gitdir;
|
||||
static const char *gitdir;
|
||||
|
||||
gitdir = offset == cwd->len ? "." : xmemdupz(cwd->buf, offset);
|
||||
if (chdir(cwd->buf))
|
||||
|
||||
Reference in New Issue
Block a user