]> git.ipfire.org Git - thirdparty/git.git/commit
object-name: free leaking object contexts
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:19:59 +0000 (11:19 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:05 +0000 (13:15 -0700)
commitf87c55c2647cf3aa0e6b5e45738facb6b62fe37c
tree1b098b88ceb32ecad516fbd68b93642a5488fd8e
parent61f8bb1ec1ef6022c2e7994b8b896ab158d7070b
object-name: free leaking object contexts

While it is documented in `struct object_context::path` that this
variable needs to be released by the caller, this fact is rather easy to
miss given that we do not ever provide a function to release the object
context. And of course, while some callers dutifully release the path,
many others don't.

Introduce a new `object_context_release()` function that releases the
path. Convert callsites that used to free the path to use that new
function and add missing calls to callsites that were leaking memory.
Refactor those callsites as required to have a single return path, only.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/cat-file.c
builtin/grep.c
builtin/log.c
builtin/ls-tree.c
builtin/rev-parse.c
builtin/stash.c
list-objects-filter.c
object-name.c
object-name.h
revision.c
t/t7012-skip-worktree-writing.sh