summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2017-05-04 13:56:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-08 03:18:19 (GMT)
commitda6f847559d8794f25da9f7c090929baebce7751 (patch)
tree63fe2bd5a22d023c7b1c756056cfd9ccf59cd85c /setup.c
parent41fc6b33fc0cef748f84906810bb36fcd491f0a1 (diff)
downloadgit-da6f847559d8794f25da9f7c090929baebce7751.zip
git-da6f847559d8794f25da9f7c090929baebce7751.tar.gz
git-da6f847559d8794f25da9f7c090929baebce7751.tar.bz2
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>
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/setup.c b/setup.c
index 0309c27..0320a9a 100644
--- a/setup.c
+++ b/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))