[PATCH 13/16] packfile: ensure `close_pack_revindex()` frees in-memory revindex
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Mar 29, 2026, 21:41 UTC
- Message-ID
- <e304e316ac4d4e92125e2e57b32fa445acf66e3e.1774820449.git.me@ttaylorr.com>
- In-Reply-To
- <cover.1774820449.git.me@ttaylorr.com>
The following commit will introduce a case where we write a MIDX bitmap over packs that do not themselves have on-disk *.rev files.
This case is supported within Git, and we will simply fall back to generating the revindex in memory. But we don't ever release that memory, causing a leak that is exposed by a test introduced in the following commit.
(As far as I could find, we never free()'d memory allocated as a byproduct of creating an in-memory revindex, likely because that code predates the leak-checking niceties we have in the test suite now.)
Rectify this by calling `FREE_AND_NULL()` on the `p->revindex` field when calling `close_pack_revindex()`.
Signed-off-by: Taylor Blau <me@ttaylorr.com> --- packfile.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/packfile.c b/packfile.c index d4de9f3ffe8..97f7662e079 100644 --- a/packfile.c +++ b/packfile.c @@ -420,6 +420,8 @@ void close_pack_index(struct packed_git *p) static void close_pack_revindex(struct packed_git *p) { + FREE_AND_NULL(p->revindex); + if (!p->revindex_map) return;
-- 2.53.0.729.g817728289e1.dirty