rerere: fix various trivial leaks
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>
Patrick Steinhardt committed
Jun 11, 2024 at 11:20 UTC
f46ede661face3c57f31097960c00325cf21f67f
4 files changed
+6
rerere.c
+3
@@ -849,6 +849,8 @@ static int do_plain_rerere(struct repository *r,
849
if (update.nr)
850
update_paths(r, &update);
851
852
+ string_list_clear(&conflict, 0);
853
+ string_list_clear(&update, 0);
854
return write_rr(rr, fd);
855
}
856
@@ -912,6 +914,7 @@ int repo_rerere(struct repository *r, int flags)
914
return 0;
915
status = do_plain_rerere(r, &merge_rr, fd);
916
free_rerere_dirs();
917
+ string_list_clear(&merge_rr, 1);
918
return status;
919
}
920
t/t1021-rerere-in-workdir.sh
+1
@@ -4,6 +4,7 @@ test_description='rerere run in a workdir'
4
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7
+TEST_PASSES_SANITIZE_LEAK=true
8
. ./test-lib.sh
9
10
test_expect_success SYMLINKS setup '
t/t3504-cherry-pick-rerere.sh
+1
@@ -5,6 +5,7 @@ test_description='cherry-pick should rerere for conflicts'
5
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8
+TEST_PASSES_SANITIZE_LEAK=true
9
. ./test-lib.sh
10
11
test_expect_success setup '
t/t7600-merge.sh
+1
@@ -29,6 +29,7 @@ Testing basic merge operations/option parsing.
29
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
30
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
31
32
+TEST_PASSES_SANITIZE_LEAK=true
33
. ./test-lib.sh
34
. "$TEST_DIRECTORY"/lib-gpg.sh
35