mirror of
https://github.com/git/git
synced 2024-09-29 21:27:13 +00:00
revision: fix memory leak when reversing revisions
When reversing revisions in a rev walk, `get_revision()` will allocate a new commit list and assign it to `revs->commits`. It does not free the old list though, which makes it leak. Fix this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
03b0e7d3a7
commit
56931c4d89
|
@ -4430,6 +4430,7 @@ struct commit *get_revision(struct rev_info *revs)
|
|||
reversed = NULL;
|
||||
while ((c = get_revision_internal(revs)))
|
||||
commit_list_insert(c, &reversed);
|
||||
free_commit_list(revs->commits);
|
||||
revs->commits = reversed;
|
||||
revs->reverse = 0;
|
||||
revs->reverse_output_stage = 1;
|
||||
|
|
|
@ -5,6 +5,7 @@ test_description='test cherry-picking many commits'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
check_head_differs_from() {
|
||||
|
|
Loading…
Reference in a new issue