setup_bare_git_dir(): fix memory leak

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2017-04-18 14:09:23 +02:00
parent 0c405aa991
commit a26de53cee

View File

@@ -740,7 +740,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))