summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2023-11-06 11:46:05 +0100
committerJunio C Hamano <gitster@pobox.com>2023-11-07 08:51:41 +0900
commit9972cd6004ac46a919d2e8773be976ef1e2d6a65 (patch)
tree7f17ea08cb8fe64e533fcbdb6dd5107f752d508b
parent4ce14e13250e824b7d410d9bff88061525346a15 (diff)
downloadgit-9972cd6004ac46a919d2e8773be976ef1e2d6a65.tar.gz
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--setup.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/setup.c b/setup.c
index b9474b163a..fc592dc6dd 100644
--- a/setup.c
+++ b/setup.c
@@ -722,6 +722,7 @@ int upgrade_repository_format(int target_version)
ret = 1;
out:
+ clear_repository_format(&repo_fmt);
strbuf_release(&repo_version);
strbuf_release(&err);
return ret;
@@ -2199,6 +2200,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
git_dir, len && git_dir[len-1] != '/' ? "/" : "");
}
+ clear_repository_format(&repo_fmt);
free(original_git_dir);
return 0;
}