From: Kaartic Sivaraam Date: Tue, 15 Sep 2026 08:29:36 GMT Subject: [PATCH v4] builtin/history: unuse the commit buffer after use Message-ID: <20260915082943.117985-1-kaartic.sivaraam@gmail.com> In-Reply-To: <20260910150021.348548-1-kaartic.sivaraam@gmail.com> 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 --- Changes since v3: - Replaced the long commit message with the concise one suggested by Peff. builtin/history.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/history.c b/builtin/history.c index 091465a59e..0e9259b5d7 100644 --- a/builtin/history.c +++ b/builtin/history.c @@ -154,6 +154,7 @@ static int commit_tree_ext(struct repository *repo, 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; } -- 2.55.0.801.g894675e619