From 0e75d17ff78498645bf5d71df3a14a40d2fe1298 Mon Sep 17 00:00:00 2001 From: Kaartic Sivaraam Date: Tue, 15 Sep 2026 13:59:36 +0530 Subject: [PATCH] builtin/history: unuse the commit buffer after use Every call to repo_logmsg_reencode() must be paired with a call to repo_unuse_commit_buffer(), or we may leak an allocated buffer. We have such a leak in "git history", which we can fix by adding an unuse call. The leak-checking tests don't detect this because we only allocate a fresh buffer sometimes: when the message is reencoded, or when we had to load it fresh from the odb (e.g., because the commit was parsed from the commit graph rather than the object contents). But you can see it by running: make SANITIZE=leak cd t GIT_TEST_COMMIT_GRAPH=1 ./t3451-history-reword.sh Helped-by: Jeff King Signed-off-by: Kaartic Sivaraam Signed-off-by: Junio C Hamano --- builtin/history.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/history.c b/builtin/history.c index 000155ad9c..4f94221b11 100644 --- a/builtin/history.c +++ b/builtin/history.c @@ -161,6 +161,7 @@ out: free_commit_extra_headers(original_extra_headers); strbuf_release(&commit_message); free(original_author); + repo_unuse_commit_buffer(repo, commit_with_message, original_message); return ret; }