]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repository: fix repo_init() memleak due to missing _clear()
authorAdrian Ratiu <adrian.ratiu@collabora.com>
Fri, 10 Apr 2026 09:05:56 +0000 (12:05 +0300)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Apr 2026 14:58:52 +0000 (07:58 -0700)
There is an old pre-existing memory leak in repo_init() due to failing
to call clear_repository_format() in the error case.

It went undetected because a specific bug is required to trigger it:
enable a v1 extension in a repository with format v0. Obviously this
can only happen in a development environment, so it does not trigger
in normal usage, however the memleak is real and needs fixing.

Fix it by also calling clear_repository_format() in the error case.

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
repository.c

index 9e5537f53961ed3ace4135be10435b7054c12916..192d6dc9c477fa44538fe4d5c701b89e7c760e35 100644 (file)
@@ -323,6 +323,7 @@ int repo_init(struct repository *repo,
        return 0;
 
 error:
+       clear_repository_format(&format);
        repo_clear(repo);
        return -1;
 }