Skip to content

Commit f46ede6

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 748bd09 commit f46ede6

File tree

4 files changed

+6
-0
lines changed

4 files changed

+6
-0
lines changed

rerere.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,8 @@ static int do_plain_rerere(struct repository *r,
849849
if (update.nr)
850850
update_paths(r, &update);
851851

852+
string_list_clear(&conflict, 0);
853+
string_list_clear(&update, 0);
852854
return write_rr(rr, fd);
853855
}
854856

@@ -912,6 +914,7 @@ int repo_rerere(struct repository *r, int flags)
912914
return 0;
913915
status = do_plain_rerere(r, &merge_rr, fd);
914916
free_rerere_dirs();
917+
string_list_clear(&merge_rr, 1);
915918
return status;
916919
}
917920

t/t1021-rerere-in-workdir.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='rerere run in a workdir'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7+
TEST_PASSES_SANITIZE_LEAK=true
78
. ./test-lib.sh
89

910
test_expect_success SYMLINKS setup '

t/t3504-cherry-pick-rerere.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='cherry-pick should rerere for conflicts'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910

1011
test_expect_success setup '

t/t7600-merge.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Testing basic merge operations/option parsing.
2929
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
3030
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
3131

32+
TEST_PASSES_SANITIZE_LEAK=true
3233
. ./test-lib.sh
3334
. "$TEST_DIRECTORY"/lib-gpg.sh
3435

0 commit comments

Comments
 (0)