diff mbox series

[13/29] merge-recursive: fix memory leak when finalizing merge

Message ID 930de119116355f0b6df9e7e1d5d0fe38d93755a.1717402439.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series Memory leak fixes (pt.2) | expand

Commit Message

Patrick Steinhardt June 3, 2024, 9:47 a.m. UTC
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>
---
 merge-recursive.c               | 3 +++
 t/t1004-read-tree-m-u-wf.sh     | 1 +
 t/t1015-read-index-unmerged.sh  | 2 ++
 t/t3509-cherry-pick-merge-df.sh | 1 +
 4 files changed, 7 insertions(+)

Comments

karthik nayak June 6, 2024, 10:50 a.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> We do not free some members of `struct merge_options`' private data.

Nit: s/`struct merge_options`'/`struct merge_options`'s/

[snip]
Phillip Wood June 6, 2024, 3:52 p.m. UTC | #2
On 06/06/2024 11:50, Karthik Nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
>> We do not free some members of `struct merge_options`' private data.
> 
> Nit: s/`struct merge_options`'/`struct merge_options`'s/

Either is correct, it is a matter of style whether one adds the trailing 
"s".

Best Wishes

Phillip
karthik nayak June 12, 2024, 9:33 a.m. UTC | #3
Phillip Wood <phillip.wood123@gmail.com> writes:

> On 06/06/2024 11:50, Karthik Nayak wrote:
>> Patrick Steinhardt <ps@pks.im> writes:
>>
>>> We do not free some members of `struct merge_options`' private data.
>>
>> Nit: s/`struct merge_options`'/`struct merge_options`'s/
>
> Either is correct, it is a matter of style whether one adds the trailing
> "s".
>
> Best Wishes
>
> Phillip

TIL, thanks Phillip.
diff mbox series

Patch

diff --git a/merge-recursive.c b/merge-recursive.c
index eff73dac02..832c8ef3f3 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -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);
 }
 
diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh
index 11bf10424f..2b9720b0fe 100755
--- a/t/t1004-read-tree-m-u-wf.sh
+++ b/t/t1004-read-tree-m-u-wf.sh
@@ -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
 
diff --git a/t/t1015-read-index-unmerged.sh b/t/t1015-read-index-unmerged.sh
index 55d22da32c..da737a32a2 100755
--- a/t/t1015-read-index-unmerged.sh
+++ b/t/t1015-read-index-unmerged.sh
@@ -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' '
diff --git a/t/t3509-cherry-pick-merge-df.sh b/t/t3509-cherry-pick-merge-df.sh
index f4159246e1..171cc6d76b 100755
--- a/t/t3509-cherry-pick-merge-df.sh
+++ b/t/t3509-cherry-pick-merge-df.sh
@@ -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' '