]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/repack: fix leaks when computing packs to repack
authorPatrick Steinhardt <ps@pks.im>
Thu, 22 Aug 2024 09:17:36 +0000 (11:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2024 16:18:04 +0000 (09:18 -0700)
commitbda97cb1199919a192cc821a9e03b810b7d96f8f
tree929d956fb6e483c1233935f69451c9553683b33e
parent8a7846383e80ad3370344d752c5bb3a2c78cbf65
builtin/repack: fix leaks when computing packs to repack

When writing an MIDX in git-repack(1) we first collect all the pack
names that we want to add to it in a string list. This list is marked as
`NODUP`, which indicates that it will neither duplicate nor own strings
added to it. In `write_midx_included_packs()` we then `insert()` strings
via `xstrdup()` or `strbuf_detach()`, but the resulting strings will not
be owned by anything and thus leak.

Fix this issue by marking the list as `DUP` and using a local buffer to
compute the pack names.

This leak is hit in t5319, but plugging it is not sufficient to make the
whole test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c