Commit
a5a7e86df19a720a611d4a149fd77435414ac62f
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt <ps@pks.im> · 2026-09-11 05:51 UTC · committed by Junio C Hamano
1 file changed,
+1
−0
modified odb/source-packed.c
| @@ -844,6 +844,7 @@ static void odb_source_packed_free(struct odb_source *source) | |||
| 844 | 844 | ||
| 845 | 845 | chdir_notify_unregister(odb_source_packed_reparent, packed); | |
| 846 | 846 | ||
| 847 | + | odb_source_close(source); | |
| 847 | 848 | for (struct packfile_list_entry *e = packed->packs.head; e; e = e->next) | |
| 848 | 849 | free(e->pack); | |
| 849 | 850 | packfile_list_clear(&packed->packs); | |