]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repository: free main reference database
authorPatrick Steinhardt <ps@pks.im>
Thu, 25 Jun 2026 09:20:04 +0000 (11:20 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Jun 2026 20:19:57 +0000 (13:19 -0700)
While we release worktree and submodule reference databases when
clearing a repository, we don't ever release the main reference
database. This memory leak went unnoticed because its pointer is
kept alive by the "chdir_notify" subsystem.

Fix the memory leak.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
repository.c

index 187dd471c4e607910f093aec6cdb641f382d1229..e2b5c6712b9367d11727441c7fd8c74c35f605d9 100644 (file)
@@ -421,6 +421,11 @@ void repo_clear(struct repository *repo)
                FREE_AND_NULL(repo->remote_state);
        }
 
+       if (repo->refs_private) {
+               ref_store_release(repo->refs_private);
+               FREE_AND_NULL(repo->refs_private);
+       }
+
        strmap_for_each_entry(&repo->submodule_ref_stores, &iter, e)
                ref_store_release(e->value);
        strmap_clear(&repo->submodule_ref_stores, 1);