]> git.ipfire.org Git - thirdparty/git.git/commitdiff
scalar: fix leaking repositories
authorPatrick Steinhardt <ps@pks.im>
Mon, 30 Sep 2024 09:13:15 +0000 (11:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2024 18:23:02 +0000 (11:23 -0700)
In the scalar code we iterate through multiple repositories,
initializing each of them. We never clear them though, causing memory
leaks. Plug them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
scalar.c
t/t9210-scalar.sh
t/t9211-scalar-clone.sh

index 09560aeab5418b82f39840473d98bc8792ac32ba..ede616ad4f1a9c4c228a94b09a3bf1ba4cdb76c3 100644 (file)
--- a/scalar.c
+++ b/scalar.c
@@ -732,6 +732,7 @@ static int cmd_reconfigure(int argc, const char **argv)
                        succeeded = 1;
 
                the_repository = old_repo;
+               repo_clear(&r);
 
 loop_end:
                if (!succeeded) {
index e8613990e13705aed6c3cd6f1e1b44edc1e771c6..a131a6c02991f449bec10cd54d640546e0696d80 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='test the `scalar` command'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt,launchctl:true,schtasks:true"
index 7869f45ee646dd511b16e404a8b165200f9c8608..c16ea67c1dc36631b222db6c45dbbd62d0014c0a 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='test the `scalar clone` subcommand'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "${TEST_DIRECTORY}/lib-terminal.sh"