summaryrefslogtreecommitdiff
path: root/worktree.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2017-05-04 15:59:19 +0200
committerJunio C Hamano <gitster@pobox.com>2017-05-08 12:18:20 +0900
commitd32de66a07c600c14f70e6d435f8f9c496b0d625 (patch)
tree4f8767001b38734d53b81b56145e8862a05f4568 /worktree.c
parent2e11f58fa6a0c904d9b00e51cfb2d8a3ee77b360 (diff)
downloadgit-d32de66a07c600c14f70e6d435f8f9c496b0d625.tar.gz
submodule_uses_worktrees(): plug memory leak
There is really no reason why we would need to hold onto the allocated string longer than necessary. Reported by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.c')
-rw-r--r--worktree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/worktree.c b/worktree.c
index bae787cf8d..89a81b13de 100644
--- a/worktree.c
+++ b/worktree.c
@@ -399,6 +399,7 @@ int submodule_uses_worktrees(const char *path)
/* The env would be set for the superproject. */
get_common_dir_noenv(&sb, submodule_gitdir);
+ free(submodule_gitdir);
/*
* The check below is only known to be good for repository format
@@ -418,7 +419,6 @@ int submodule_uses_worktrees(const char *path)
/* See if there is any file inside the worktrees directory. */
dir = opendir(sb.buf);
strbuf_release(&sb);
- free(submodule_gitdir);
if (!dir)
return 0;