Skip to content

Commit de54b45

Browse files
pks-tgitster
authored andcommitted
merge-ort: unconditionally release attributes index
We conditionally release the index used for reading gitattributes in merge-ort based on whether or the index has been populated. This check uses `cache_nr` as a condition. This isn't sufficient though, as the variable may be zero even when some other parts of the index have been populated. This leads to memory leaks when sparse checkouts are in use, as we may not end up releasing the sparse checkout patterns. Fix this issue by unconditionally releasing the index. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a0b8262 commit de54b45

File tree

5 files changed

+5
-2
lines changed

5 files changed

+5
-2
lines changed

merge-ort.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,7 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
689689
*/
690690
strmap_clear_func(&opti->conflicted, 0);
691691

692-
if (opti->attr_index.cache_nr) /* true iff opt->renormalize */
693-
discard_index(&opti->attr_index);
692+
discard_index(&opti->attr_index);
694693

695694
/* Free memory used by various renames maps */
696695
for (i = MERGE_SIDE1; i <= MERGE_SIDE2; ++i) {

t/t3507-cherry-pick-conflict.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
1313
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1414

1515
TEST_CREATE_REPO_NO_TEMPLATE=1
16+
TEST_PASSES_SANITIZE_LEAK=true
1617
. ./test-lib.sh
1718

1819
pristine_detach () {

t/t6421-merge-partial-clone.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ test_description="limiting blob downloads when merging with partial clones"
2626
# underscore notation is to differentiate different
2727
# files that might be renamed into each other's paths.)
2828

29+
TEST_PASSES_SANITIZE_LEAK=true
2930
. ./test-lib.sh
3031
. "$TEST_DIRECTORY"/lib-merge.sh
3132

t/t6428-merge-conflicts-sparse.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ test_description="merge cases"
2222
# underscore notation is to differentiate different
2323
# files that might be renamed into each other's paths.)
2424

25+
TEST_PASSES_SANITIZE_LEAK=true
2526
. ./test-lib.sh
2627
. "$TEST_DIRECTORY"/lib-merge.sh
2728

t/t7817-grep-sparse-checkout.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ should leave the following structure in the working tree:
3333
But note that sub2 should have the SKIP_WORKTREE bit set.
3434
'
3535

36+
TEST_PASSES_SANITIZE_LEAK=true
3637
. ./test-lib.sh
3738

3839
test_expect_success 'setup' '

0 commit comments

Comments
 (0)