]> git.ipfire.org Git - thirdparty/git.git/commit
object-name: fix leaking commit list items
authorPatrick Steinhardt <ps@pks.im>
Thu, 1 Aug 2024 10:41:01 +0000 (12:41 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Aug 2024 15:47:37 +0000 (08:47 -0700)
commit57fb139b5ee7dcb2ea5182bf33bcd2b07df983c9
tree275d3fe9bf76a8db25976b5eda5271a99570fb52
parent11f841c1cc9c7ffadf5d462d25a378fcab5bb6e1
object-name: fix leaking commit list items

When calling `get_oid_oneline()`, we pass in a `struct commit_list` that
gets modified by the function. This creates a weird situation where the
commit list may sometimes be empty after returning, but sometimes it
will continue to carry additional commits. In those cases the remainder
of the list leaks.

Ultimately, the design where we only pass partial ownership to
`get_oid_oneline()` feels shoddy. Refactor the code such that we only
pass a constant pointer to the list, creating a local copy as needed.
Callers are thus always responsible for freeing the commit list, which
then allows us to plug a bunch of memory leaks.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-name.c
t/t1511-rev-parse-caret.sh
t/t6133-pathspec-rev-dwim.sh