Skip to content

Commit b0f568f

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
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 <[email protected]>
1 parent 6d85344 commit b0f568f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

worktree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ int submodule_uses_worktrees(const char *path)
399399

400400
/* The env would be set for the superproject. */
401401
get_common_dir_noenv(&sb, submodule_gitdir);
402+
free(submodule_gitdir);
402403

403404
/*
404405
* The check below is only known to be good for repository format
@@ -418,7 +419,6 @@ int submodule_uses_worktrees(const char *path)
418419
/* See if there is any file inside the worktrees directory. */
419420
dir = opendir(sb.buf);
420421
strbuf_release(&sb);
421-
free(submodule_gitdir);
422422

423423
if (!dir)
424424
return 0;

0 commit comments

Comments
 (0)