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>

Johannes Schindelin committed May 4, 2017 at 15:59 UTC d32de66a07c600c14f70e6d435f8f9c496b0d625
1 file changed +1 -1
worktree.c
+1 -1
@@ -399,6 +399,7 @@ int submodule_uses_worktrees(const char *path)
399
400 /* The env would be set for the superproject. */
401 get_common_dir_noenv(&sb, submodule_gitdir);
402 + free(submodule_gitdir);
403
404 /*
405 * The check below is only known to be good for repository format
@@ -418,7 +419,6 @@ int submodule_uses_worktrees(const char *path)
419 /* See if there is any file inside the worktrees directory. */
420 dir = opendir(sb.buf);
421 strbuf_release(&sb);
421 - free(submodule_gitdir);
422
423 if (!dir)
424 return 0;