negotiator/skipping: fix leaking commit entries

When releasing the skipping negotiator we free its priority queue, but
not the contained entries. Fix this to plug a memory leak.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt 2024-09-05 12:09:20 +02:00 committed by Junio C Hamano
parent 16c6fb5a94
commit a46f231975
2 changed files with 7 additions and 2 deletions

View File

@ -247,8 +247,11 @@ static int ack(struct fetch_negotiator *n, struct commit *c)
static void release(struct fetch_negotiator *n)
{
clear_prio_queue(&((struct data *)n->data)->rev_list);
FREE_AND_NULL(n->data);
struct data *data = n->data;
for (int i = 0; i < data->rev_list.nr; i++)
free(data->rev_list.array[i].data);
clear_prio_queue(&data->rev_list);
FREE_AND_NULL(data);
}
void skipping_negotiator_init(struct fetch_negotiator *negotiator)

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='test skipping fetch negotiator'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'fetch.negotiationalgorithm config' '