object-name: fix leaking symlink paths in object context
The object context may be populated with symlink contents when reading a symlink, but the associated strbuf doesn't ever get released when releasing the object context, causing a memory leak. Plug it. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Aug 14, 2024 at 08:52 UTC
9ddd5f755d78dd2a3119b63d5f78ca93e4fd3eba
2 files changed
+2
object-name.c
+1
@@ -1765,6 +1765,7 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
1765
void object_context_release(struct object_context *ctx)
1766
{
1767
free(ctx->path);
1768
+ strbuf_release(&ctx->symlink_path);
1769
}
1770
1771
/*
t/t1006-cat-file.sh
+1
@@ -2,6 +2,7 @@
2
3
test_description='git cat-file'
4
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
8
test_cmdmode_usage () {