]> git.ipfire.org Git - thirdparty/git.git/commitdiff
negotiator/skipping: fix leaking commit entries
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Sep 2024 10:09:20 +0000 (12:09 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Sep 2024 15:49:12 +0000 (08:49 -0700)
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>
negotiator/skipping.c
t/t5552-skipping-fetch-negotiator.sh

index f65d47858b422e4f842f0eb3db76ede8ead9716b..b738fe4faeff045965f0b5255408781e9dbcde6b 100644 (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)
index b55a9f65e6bfb56b0461ca6b6da0ec03df2cda32..4f2e5ae8dfa5af1b825547a9e3701b19b8e2eaa5 100755 (executable)
@@ -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' '