]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-recursive: fix memory leak when finalizing merge
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:20:14 +0000 (11:20 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:06 +0000 (13:15 -0700)
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>
merge-recursive.c
t/t1004-read-tree-m-u-wf.sh
t/t1015-read-index-unmerged.sh
t/t3509-cherry-pick-merge-df.sh

index eff73dac02e6501b26dfc264aa6059e6f8565df0..832c8ef3f34daaaae0523a131d5c1dfd4cb38b0f 100644 (file)
@@ -3800,6 +3800,9 @@ static void merge_finalize(struct merge_options *opt)
        if (show(opt, 2))
                diff_warn_rename_limit("merge.renamelimit",
                                       opt->priv->needed_rename_limit, 0);
+       hashmap_clear_and_free(&opt->priv->current_file_dir_set,
+                              struct path_hashmap_entry, e);
+       string_list_clear(&opt->priv->df_conflict_file_set, 0);
        FREE_AND_NULL(opt->priv);
 }
 
index 11bf10424f16208cda726c612cb64bfc89d9c803..2b9720b0feb465bb9c4651626c43829ec27cd7b8 100755 (executable)
@@ -5,6 +5,7 @@ test_description='read-tree -m -u checks working tree files'
 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-read-tree.sh
 
index 55d22da32ccdca701014c655a32041d0b5b89440..da737a32a271185882b6f1fb6b190e7e82d90a48 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='Test various callers of read_index_unmerged'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup modify/delete + directory/file conflict' '
index f4159246e1e35d615bca2191393ea19427088dc0..171cc6d76b797c99638bda0d63083aecfd7a5a2d 100755 (executable)
@@ -4,6 +4,7 @@ test_description='Test cherry-pick with directory/file 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 'Initialize repository' '