[PATCH v3 04/22] object-name: fix leaking symlink paths in object context
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 13, 2024, 09:31 UTC
- Message-ID
- <e5130e50a9f296720960b2a8d7be14fc01a0fd30.1723540931.git.ps@pks.im>
- In-Reply-To
- <cover.1723540931.git.ps@pks.im>
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> --- object-name.c | 1 + t/t1006-cat-file.sh | 1 + 2 files changed, 2 insertions(+)
diff --git a/object-name.c b/object-name.c index 240a93e7ce..e39fa50e47 100644 --- a/object-name.c +++ b/object-name.c @@ -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); } /* diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index ff9bf213aa..d36cd7c086 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -2,6 +2,7 @@ test_description='git cat-file' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_cmdmode_usage () {
-- 2.46.0.46.g406f326d27.dirty