]> git.ipfire.org Git - thirdparty/git.git/commit
t/helper/test-read-midx.c: plug memory leak when selecting layer
authorTaylor Blau <me@ttaylorr.com>
Tue, 24 Feb 2026 19:00:36 +0000 (14:00 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 Feb 2026 19:16:34 +0000 (11:16 -0800)
commitdedf71f0b1b9a64d5aa7558ef45b26166d8d66fc
tree35aa6ec0bf0da86237d1cd9f402d91592b90c737
parent9aea84c4e78b462fe55d142e67997b90d8ee3055
t/helper/test-read-midx.c: plug memory leak when selecting layer

Though our 'read-midx' test tool is capable of printing information
about a single MIDX layer identified by its checksum, no caller in our
test suite exercises this path.

Unfortunately, there is a memory leak lurking in this (currently) unused
path that would otherwise be exposed by the following commit.

This occurs when providing a MIDX layer checksum other than the tip. As
we walk over the MIDX chain trying to find the matching layer, we drop
our reference to the top-most MIDX layer. Thus, our call to
'close_midx()' later on leaks memory between the top-most MIDX layer and
the MIDX layer immediately following the specified one.

Plug this leak by holding a reference to the tip of the MIDX chain, and
ensure that we call `close_midx()` before terminating the test tool.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-read-midx.c