Skip to content

Commit 6b88dd4

Browse files
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 219dce8 commit 6b88dd4

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

397397
/* The env would be set for the superproject. */
398398
get_common_dir_noenv(&sb, submodule_gitdir);
399+
free(submodule_gitdir);
399400

400401
/*
401402
* The check below is only known to be good for repository format
@@ -415,7 +416,6 @@ int submodule_uses_worktrees(const char *path)
415416
/* See if there is any file inside the worktrees directory. */
416417
dir = opendir(sb.buf);
417418
strbuf_release(&sb);
418-
free(submodule_gitdir);
419419

420420
if (!dir)
421421
return 0;

0 commit comments

Comments
 (0)