aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-09-05 12:09:20 +0200
committerJunio C Hamano <gitster@pobox.com>2024-09-05 08:49:12 -0700
commita46f231975f4c7ac94af0847f4b3bb8b11493d80 (patch)
tree7b5df02e3e4d740ba6023b50d9aff75178fad5a8
parentshallow: fix leaking members of `struct shallow_info` (diff)
downloadgit-a46f231975f4c7ac94af0847f4b3bb8b11493d80.tar.gz
git-a46f231975f4c7ac94af0847f4b3bb8b11493d80.zip
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>
-rw-r--r--negotiator/skipping.c7
-rwxr-xr-xt/t5552-skipping-fetch-negotiator.sh2
2 files changed, 7 insertions, 2 deletions
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index f65d47858b..b738fe4fae 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -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)
diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh
index b55a9f65e6..4f2e5ae8df 100755
--- a/t/t5552-skipping-fetch-negotiator.sh
+++ b/t/t5552-skipping-fetch-negotiator.sh
@@ -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' '