Skip to content

Commit 3957cee

Browse files
sceptical-coderdscho
authored andcommitted
status: fix for old-style submodules with commondir
In f9b7573 (repository: free fields before overwriting them, 2017-09-05), Git was taught to release memory before overwriting it, but 357a03e (repository.c: move env-related setup code back to environment.c, 2018-03-03) changed the code so that it would not _always_ be overwritten. As a consequence, the `commondir` attribute would point to already-free()d memory. This seems not to cause problems in core Git, but there are add-on patches in Git for Windows where the `commondir` attribute is subsequently used and causing invalid memory accesses e.g. in setups containing old-style submodules (i.e. the ones with a `.git` directory within theirs worktrees) that have `commondir` configured. This fixes #4083. Signed-off-by: Andrey Zabavnikov <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 1bdf957 commit 3957cee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

repository.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static void repo_set_commondir(struct repository *repo,
136136
{
137137
struct strbuf sb = STRBUF_INIT;
138138

139-
free(repo->commondir);
139+
FREE_AND_NULL(repo->commondir);
140140

141141
if (commondir) {
142142
repo->different_commondir = 1;

0 commit comments

Comments
 (0)