merge-recursive: fix memory leak when finalizing merge
We do not free some members of `struct merge_options`' private data. Fix this to plug those leaks. 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
8ff6bd47500dcd55d278fdbfe77fe838cc8dd3b1
4 files changed
+7
merge-recursive.c
+3
@@ -3800,6 +3800,9 @@ static void merge_finalize(struct merge_options *opt)
3800
if (show(opt, 2))
3801
diff_warn_rename_limit("merge.renamelimit",
3802
opt->priv->needed_rename_limit, 0);
3803
+ hashmap_clear_and_free(&opt->priv->current_file_dir_set,
3804
+ struct path_hashmap_entry, e);
3805
+ string_list_clear(&opt->priv->df_conflict_file_set, 0);
3806
FREE_AND_NULL(opt->priv);
3807
}
3808
t/t1004-read-tree-m-u-wf.sh
+1
@@ -5,6 +5,7 @@ test_description='read-tree -m -u checks working tree files'
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
. "$TEST_DIRECTORY"/lib-read-tree.sh
11
t/t1015-read-index-unmerged.sh
+2
@@ -1,6 +1,8 @@
1
#!/bin/sh
2
3
test_description='Test various callers of read_index_unmerged'
4
+
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
8
test_expect_success 'setup modify/delete + directory/file conflict' '
t/t3509-cherry-pick-merge-df.sh
+1
@@ -4,6 +4,7 @@ test_description='Test cherry-pick with directory/file conflicts'
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 'Initialize repository' '