Skip to content

Commit 9972cd6

Browse files
pks-tgitster
authored andcommitted
setup: fix leaking repository format
While populating the `repository_format` structure may cause us to allocate memory, we do not call `clear_repository_format()` in some places and thus potentially leak memory. Fix this. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ce14e1 commit 9972cd6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@ int upgrade_repository_format(int target_version)
722722
ret = 1;
723723

724724
out:
725+
clear_repository_format(&repo_fmt);
725726
strbuf_release(&repo_version);
726727
strbuf_release(&err);
727728
return ret;
@@ -2199,6 +2200,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
21992200
git_dir, len && git_dir[len-1] != '/' ? "/" : "");
22002201
}
22012202

2203+
clear_repository_format(&repo_fmt);
22022204
free(original_git_dir);
22032205
return 0;
22042206
}

0 commit comments

Comments
 (0)