diff mbox series

[v2,02/22] fetch-pack: fix memory leaks on fetch negotiation

Message ID 611a29d1ca30759b7c91597a580d93578382955c.1725530720.git.ps@pks.im (mailing list archive)
State Accepted
Commit 63494913eced2f0993eb431ad236b03e6ee8cac2
Headers show
Series Memory leak fixes (pt.6) | expand

Commit Message

Patrick Steinhardt Sept. 5, 2024, 10:08 a.m. UTC
We leak both the `nt_object_array` and `negotiator` structures in
`negotiate_using_fetch()`. Plug both of these leaks.

These leaks were exposed by t5516, but fixing them is not sufficient to
make the whole test suite leak free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 fetch-pack.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/fetch-pack.c b/fetch-pack.c
index 58b4581ad80..0ed82feda14 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -2227,7 +2227,10 @@  void negotiate_using_fetch(const struct oid_array *negotiation_tips,
 	trace2_region_leave("fetch-pack", "negotiate_using_fetch", the_repository);
 	trace2_data_intmax("negotiate_using_fetch", the_repository,
 			   "total_rounds", negotiation_round);
+
 	clear_common_flag(acked_commits);
+	object_array_clear(&nt_object_array);
+	negotiator.release(&negotiator);
 	strbuf_release(&req_buf);
 }