Skip to content

Commit e126386

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 0175f08 commit e126386

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
@@ -351,6 +351,7 @@ int submodule_uses_worktrees(const char *path)
351351

352352
/* The env would be set for the superproject. */
353353
get_common_dir_noenv(&sb, submodule_gitdir);
354+
free(submodule_gitdir);
354355

355356
/*
356357
* The check below is only known to be good for repository format
@@ -370,7 +371,6 @@ int submodule_uses_worktrees(const char *path)
370371
/* See if there is any file inside the worktrees directory. */
371372
dir = opendir(sb.buf);
372373
strbuf_release(&sb);
373-
free(submodule_gitdir);
374374

375375
if (!dir)
376376
return 0;

0 commit comments

Comments
 (0)