Skip to content

Commit fa01642

Browse files
pks-tgitster
authored andcommitted
revision: fix leaking parents when simplifying commits
When simplifying commits, e.g. because they are treesame with their parents, we unset the commit's parent pointers but never free them. Plug the resulting memory leaks. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b6c3f8e commit fa01642

7 files changed

+12
-0
lines changed

revision.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,11 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
10711071
ts->treesame[nth_parent] = 1;
10721072
continue;
10731073
}
1074+
1075+
free_commit_list(parent->next);
10741076
parent->next = NULL;
1077+
while (commit->parents != parent)
1078+
pop_commit(&commit->parents);
10751079
commit->parents = parent;
10761080

10771081
/*
@@ -1103,6 +1107,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
11031107
die("cannot simplify commit %s (invalid %s)",
11041108
oid_to_hex(&commit->object.oid),
11051109
oid_to_hex(&p->object.oid));
1110+
free_commit_list(p->parents);
11061111
p->parents = NULL;
11071112
}
11081113
/* fallthrough */

t/t1414-reflog-walk.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='various tests of reflog walk (log -g) behavior'
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 'set up some reflog entries' '

t/t5310-pack-bitmaps.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='exercise basic bitmap functionality'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67
. "$TEST_DIRECTORY"/lib-bitmap.sh
78

t/t5326-multi-pack-bitmaps.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='exercise basic multi-pack bitmap functionality'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57
. "${TEST_DIRECTORY}/lib-bitmap.sh"
68

t/t6004-rev-list-path-optim.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ test_description='git rev-list trivial path optimization test
1616
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
1717
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1818

19+
TEST_PASSES_SANITIZE_LEAK=true
1920
. ./test-lib.sh
2021

2122
test_expect_success setup '

t/t6019-rev-list-ancestry-path.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ test_description='--ancestry-path'
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

3435
test_merge () {

t/t6111-rev-list-treesame.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ test_description='TREESAME and limiting'
1616
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
1717
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1818

19+
TEST_PASSES_SANITIZE_LEAK=true
1920
. ./test-lib.sh
2021

2122
note () {

0 commit comments

Comments
 (0)