Skip to content

Commit a46f231

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16c6fb5 commit a46f231

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

negotiator/skipping.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,11 @@ static int ack(struct fetch_negotiator *n, struct commit *c)
247247

248248
static void release(struct fetch_negotiator *n)
249249
{
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);
252255
}
253256

254257
void skipping_negotiator_init(struct fetch_negotiator *negotiator)

t/t5552-skipping-fetch-negotiator.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='test skipping fetch negotiator'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_expect_success 'fetch.negotiationalgorithm config' '

0 commit comments

Comments
 (0)