]> git.ipfire.org Git - thirdparty/git.git/commit
submodule: fix leaking submodule ODB paths
authorPatrick Steinhardt <ps@pks.im>
Thu, 26 Sep 2024 11:46:48 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Sep 2024 15:25:36 +0000 (08:25 -0700)
commitf8d2ca7246394535dff520aac6d1a66a5a807b75
treecbd23fdd3ea8b12aa6297f4d785e9560a02f510a
parent64d9adafba5b3024414760838d9d81f68738e813
submodule: fix leaking submodule ODB paths

In `add_submodule_odb_by_path()` we add a path into a global string
list. The list is initialized with `NODUP`, which means that we do not
pass ownership of strings to the list. But we use `xstrdup()` when we
insert a path, with the consequence that the string will never get
free'd.

Plug the leak by marking the list as `DUP`. There is only a single
callsite where we insert paths anyway, and as explained above that
callsite was mishandling the allocation.

This leak is exposed by t7814, but plugging it does not make the whole
test suite pass.

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