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>
Patrick Steinhardt committed
Sep 5, 2024 at 12:09 UTC
a46f231975f4c7ac94af0847f4b3bb8b11493d80
2 files changed
+7
-2
negotiator/skipping.c
+5
-2
@@ -247,8 +247,11 @@ static int ack(struct fetch_negotiator *n, struct commit *c)
247
248
static void release(struct fetch_negotiator *n)
249
{
250
- clear_prio_queue(&((struct data *)n->data)->rev_list);
251
- FREE_AND_NULL(n->data);
250
+ struct data *data = n->data;
251
+ for (int i = 0; i < data->rev_list.nr; i++)
252
+ free(data->rev_list.array[i].data);
253
+ clear_prio_queue(&data->rev_list);
254
+ FREE_AND_NULL(data);
255
}
256
257
void skipping_negotiator_init(struct fetch_negotiator *negotiator)
t/t5552-skipping-fetch-negotiator.sh
+2
@@ -1,6 +1,8 @@
1
#!/bin/sh
2
3
test_description='test skipping fetch negotiator'
4
+
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
8
test_expect_success 'fetch.negotiationalgorithm config' '