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>

Patrick Steinhardt committed Nov 6, 2023 at 11:46 UTC 9972cd6004ac46a919d2e8773be976ef1e2d6a65
1 file changed +2
setup.c
+2
@@ -722,6 +722,7 @@ int upgrade_repository_format(int target_version)
722 ret = 1;
723
724 out:
725 + clear_repository_format(&repo_fmt);
726 strbuf_release(&repo_version);
727 strbuf_release(&err);
728 return ret;
@@ -2199,6 +2200,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
2200 git_dir, len && git_dir[len-1] != '/' ? "/" : "");
2201 }
2202
2203 + clear_repository_format(&repo_fmt);
2204 free(original_git_dir);
2205 return 0;
2206 }