]> git.ipfire.org Git - thirdparty/git.git/commit - submodule.c
submodule.c: free() memory from xgetcwd()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 1 Jul 2022 10:42:52 +0000 (12:42 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Jul 2022 18:43:42 +0000 (11:43 -0700)
commitbc57ba1d54f3133cd46481532d97a8346b62d8aa
tree82ee691699da80364b176244fb3c1dc42cf6e647
parent74a06a9f2103332d50ddc17dcd6a0a153a5e377d
submodule.c: free() memory from xgetcwd()

Fix a memory leak in code added in bf0231c6614 (rev-parse: add
--show-superproject-working-tree, 2017-03-08), we should never have
made the result of xgetcwd() a "const char *", as we return a
strbuf_detach()'d value. Let's fix that and free() it when we're done
with it.

We can't mark any tests passing passing with SANITIZE=leak using
"TEST_PASSES_SANITIZE_LEAK=true" as a result of this change, but
e.g. "t/t1500-rev-parse.sh" now gets closer to passing.

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