]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rerere: fix various trivial leaks
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:20:33 +0000 (11:20 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:06 +0000 (13:15 -0700)
We leak various different string lists in the rerere code. Free those to
plug them.

Note that the `merge_rr` variable is intentionally being free'd with the
`free_util` parameter set to 1. The `util` field is used there to store
the IDs of every rerere item and thus needs to be freed, as well.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rerere.c
t/t1021-rerere-in-workdir.sh
t/t3504-cherry-pick-rerere.sh
t/t7600-merge.sh

index c7e1f8fd25c73ca4630f3682af5ed333858324b0..10382da55cec7538476172aacca8e1aa4b991249 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -849,6 +849,8 @@ static int do_plain_rerere(struct repository *r,
        if (update.nr)
                update_paths(r, &update);
 
+       string_list_clear(&conflict, 0);
+       string_list_clear(&update, 0);
        return write_rr(rr, fd);
 }
 
@@ -912,6 +914,7 @@ int repo_rerere(struct repository *r, int flags)
                return 0;
        status = do_plain_rerere(r, &merge_rr, fd);
        free_rerere_dirs();
+       string_list_clear(&merge_rr, 1);
        return status;
 }
 
index 0b892894eb9031d88aa26cf43fc09235a2aa07bc..69bf9476cbf65dc39ac6460774938773424b61cf 100755 (executable)
@@ -4,6 +4,7 @@ test_description='rerere run in a workdir'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success SYMLINKS setup '
index 4581ae98b87cf1f05d018cfc07599e8e26d256da..597c98e9c577532fed4f729070b67577575b8950 100755 (executable)
@@ -5,6 +5,7 @@ test_description='cherry-pick should rerere for conflicts'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success setup '
index e5ff073099a983d0da7205d3a3325af28caf8a9b..041f1077b073bb493fe80c184e30b568c71f46b1 100755 (executable)
@@ -29,6 +29,7 @@ Testing basic merge operations/option parsing.
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-gpg.sh