From 6543910badb5155ba223655a55d839b2cc5817f2 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 1 Sep 2026 13:09:07 +0200 Subject: [PATCH] odb/packed: fix memory leaks when freeing source When freeing a "packed" source we don't close either its packs nor its multi-pack indices. This can cause memory leaks in case we create an ad-hoc packed source. As we used to always link packed sources to the main object database we never noticed this issue until now, but it's going to surface in subsequent commits where we stop linking them. Plug the memory leaks by closing the source first. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- odb/source-packed.c | 1 + 1 file changed, 1 insertion(+) diff --git a/odb/source-packed.c b/odb/source-packed.c index 1d90e714e6..166e76e2d6 100644 --- a/odb/source-packed.c +++ b/odb/source-packed.c @@ -844,6 +844,7 @@ static void odb_source_packed_free(struct odb_source *source) chdir_notify_unregister(odb_source_packed_reparent, packed); + odb_source_close(source); for (struct packfile_list_entry *e = packed->packs.head; e; e = e->next) free(e->pack); packfile_list_clear(&packed->packs);