diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-06-11 11:19:59 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-06-11 22:15:05 +0200 |
commit | f87c55c2647cf3aa0e6b5e45738facb6b62fe37c (patch) | |
tree | 1b098b88ceb32ecad516fbd68b93642a5488fd8e /builtin/rev-parse.c | |
parent | builtin/rev-list: fix leaking bitmap index when calculating disk usage (diff) | |
download | git-f87c55c2647cf3aa0e6b5e45738facb6b62fe37c.tar.xz git-f87c55c2647cf3aa0e6b5e45738facb6b62fe37c.zip |
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>
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r-- | builtin/rev-parse.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index ab8a8f3b0e..2e64f5bda7 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -1128,6 +1128,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) } if (!get_oid_with_context(the_repository, name, flags, &oid, &unused)) { + object_context_release(&unused); if (output_algo) repo_oid_to_algop(the_repository, &oid, output_algo, &oid); @@ -1137,6 +1138,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) show_rev(type, &oid, name); continue; } + object_context_release(&unused); if (verify) die_no_single_rev(quiet); if (has_dashdash) |