git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4] builtin/history: unuse the commit buffer after use

From
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date
Sep 15, 2026, 08:29 UTC
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 <peff@peff.net>
Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
---
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
Previous: Kaartic Sivaraam
Message 17 of 17 in “builtin/history: unuse the commit buffer after use”
  1. builtin/history: unuse the commit buffer after useKaartic Sivaraam, Jun 14, 2026
  2. Patrick SteinhardtJun 15, 2026
  3. Jeff KingJun 15, 2026
  4. Patrick SteinhardtJun 16, 2026
  5. Kaartic SivaraamJun 30, 2026
  6. Jeff KingJun 30, 2026
  7. Kaartic SivaraamJun 30, 2026
  8. Jeff KingJun 30, 2026
  9. Jeff KingJun 30, 2026
  10. Jeff KingJun 30, 2026
  11. builtin/history: unuse the commit buffer after useKaartic Sivaraam, Sep 10, 2026
  12. Junio C HamanoSep 10, 2026
  13. builtin/history: unuse the commit buffer after useKaartic Sivaraam, Sep 10, 2026
  14. Jeff KingSep 10, 2026
  15. Junio C HamanoSep 10, 2026
  16. Kaartic SivaraamSep 10, 2026
  17. builtin/history: unuse the commit buffer after useKaartic Sivaraam, Sep 15, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.