]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-name: fix leaking symlink paths in object context
authorPatrick Steinhardt <ps@pks.im>
Wed, 14 Aug 2024 06:52:00 +0000 (08:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Aug 2024 17:07:57 +0000 (10:07 -0700)
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>
object-name.c
t/t1006-cat-file.sh

index 240a93e7cef52f45c6354a7019417c7946b6b27a..e39fa50e47ea87b2e9001e2212972e6d63ffabde 100644 (file)
@@ -1765,6 +1765,7 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
 void object_context_release(struct object_context *ctx)
 {
        free(ctx->path);
+       strbuf_release(&ctx->symlink_path);
 }
 
 /*
index ff9bf213aa2c73e42ab82d9b227fbbb7049c1e43..d36cd7c0863591d197cfc3ef340972943ff40e6f 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='git cat-file'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_cmdmode_usage () {