Skip to content

Commit da6f847

Browse files
dschogitster
authored andcommitted
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 41fc6b3 commit da6f847

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
748748

749749
/* --work-tree is set without --git-dir; use discovered one */
750750
if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) {
751-
const char *gitdir;
751+
static const char *gitdir;
752752

753753
gitdir = offset == cwd->len ? "." : xmemdupz(cwd->buf, offset);
754754
if (chdir(cwd->buf))

0 commit comments

Comments
 (0)