]> git.ipfire.org Git - thirdparty/git.git/commitdiff
packfile: ensure `close_pack_revindex()` frees in-memory revindex
authorTaylor Blau <me@ttaylorr.com>
Tue, 19 May 2026 15:58:16 +0000 (11:58 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 May 2026 02:31:14 +0000 (11:31 +0900)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
packfile.c

index b012d648adaf2e7f0a76fe539a0d0899b072249d..a1e88fdb223b8b0676c0559ab837cbffe1e6bfd1 100644 (file)
@@ -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;