]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/fast-export: plug leaking tag names
authorPatrick Steinhardt <ps@pks.im>
Wed, 14 Aug 2024 06:52:31 +0000 (08:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Aug 2024 17:07:59 +0000 (10:07 -0700)
commita0b82622cbb31de66d7f5f0b1e39f349edaeb009
tree2a4b8fe8de45e8cb967b753106a2e3be07bccad6
parent8ed4e96b5bcbd98e8d9f4593d53d8729280f47b9
builtin/fast-export: plug leaking tag names

When resolving revisions in `get_tags_and_duplicates()`, we only
partially manage the lifetime of `full_name`. In fact, managing its
lifetime properly is almost impossible because we put direct pointers to
that variable into multiple lists without duplicating the string. The
consequence is that these strings will ultimately leak.

Refactor the code to make the lists we put those names into duplicate
the memory. This allows us to properly free the string as required and
thus plugs the memory leak.

While this requires us to allocate more data overall, it shouldn't be
all that bad given that the number of allocations corresponds with the
number of command line parameters, which typically aren't all that many.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fast-export.c
t/t9351-fast-export-anonymize.sh