]> git.ipfire.org Git - thirdparty/git.git/commit
index-pack: fix memory leaks
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 4 Mar 2022 18:32:04 +0000 (19:32 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 4 Mar 2022 21:24:17 +0000 (13:24 -0800)
commitf2bcc69e7ecbd80fe1de81a196c97173f33785b5
treeaea17c2ecdf83f483724961c499107c4eb0db2a2
parent715d08a9e51251ad8290b181b6ac3b9e1f9719d7
index-pack: fix memory leaks

Fix various memory leaks in "git index-pack", due to how tightly
coupled this command is with the revision walking this doesn't make
any new tests pass.

But e.g. this now passes, and had several failures before, i.e. we
still have failures in tests 3, 5 etc., which are being skipped here.

    ./t5300-pack-object.sh --run=1-2,4,6-27,30-42

It is a bit odd that we'll free "opts.anomaly", since the "opts" is a
"struct pack_idx_option" declared in pack.h. In pack-write.c there's a
reset_pack_idx_option(), but it only wipes the contents, but doesn't
free() anything.

Doing this here in cmd_index_pack() is correct because while the
struct is declared in pack.h, this code in builtin/index-pack.c (in
read_v2_anomalous_offsets()) is what allocates the "opts.anomaly", so
we should also free it here.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/index-pack.c