Skip to content

Commit 9ddd5f7

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa9ef61 commit 9ddd5f7

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

object-name.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
17651765
void object_context_release(struct object_context *ctx)
17661766
{
17671767
free(ctx->path);
1768+
strbuf_release(&ctx->symlink_path);
17681769
}
17691770

17701771
/*

t/t1006-cat-file.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='git cat-file'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
test_cmdmode_usage () {

0 commit comments

Comments
 (0)