]> git.ipfire.org Git - thirdparty/git.git/commit
bundle cmd: stop leaking memory from parse_options_cmd_bundle()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 2 Jul 2021 09:57:30 +0000 (11:57 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Jul 2021 19:10:16 +0000 (12:10 -0700)
commitdb6bfb9fe8098b8795d8e6bb8c6d85fd39f2cdaf
tree209aeb7f7b31e9f30ce5052fd5dc917200d5ee7f
parent670b81a890388c60b7032a4f5b879f2ece8c4558
bundle cmd: stop leaking memory from parse_options_cmd_bundle()

Fix a memory leak from the prefix_filename() function introduced with
its use in 3b754eedd5 (bundle: use prefix_filename with bundle path,
2017-03-20).

As noted in that commit the leak was intentional as a part of being
sloppy about freeing resources just before we exit, I'm changing this
because I'll be fixing other memory leaks in the bundle API (including
the library version) in subsequent commits. It's easier to reason
about those fixes if valgrind runs cleanly at the end without any
leaks whatsoever.

An earlier version of this change[1] went out of its way to not leak
memory on the die() codepaths here, but doing so will only avoid
reports of potential leaks under heap-only leak trackers such as
valgrind, not the SANITIZE=leak mode.

Avoiding those leaks as well might be useful to enable us to run
cleanly under the likes of valgrind in the future. But for now the
relative verbosity of the resulting code, and the fact that we don't
have some valgrind or SANITIZE=leak mode as part of our CI (it's only
run ad-hoc, see [2]), means we're not worrying about that for now.

1. https://lore.kernel.org/git/87v95vdxrc.fsf@evledraar.gmail.com/
2. https://lore.kernel.org/git/87czsv2idy.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/bundle.c