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

[PATCH] history: initialize rev_info in cmd_history_reword()

From
René Scharfe <l.s.r@web.de>
Date
Mar 8, 2026, 09:57 UTC
Message-ID
<b0b8633f-be95-48eb-8244-d0e3f1a7be72@web.de>

git history reword expects a single valid revision argument and errors out if it doesn't get it. In that case the struct rev_info passed to release_revisions() for cleanup is still uninitialized, which can result in attempts to free(3) random pointers. Avoid that by initializing the structure.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 builtin/history.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/history.c b/builtin/history.c
index 1cf6c668cf..88822a184f 100644
--- a/builtin/history.c
+++ b/builtin/history.c
@@ -425,7 +425,7 @@ static int cmd_history_reword(int argc,
 	};
 	struct strbuf reflog_msg = STRBUF_INIT;
 	struct commit *original, *rewritten;
-	struct rev_info revs;
+	struct rev_info revs = { 0 };
 	int ret;
 
 	argc = parse_options(argc, argv, prefix, options, usage, 0);
-- 
2.53.0
Next: Patrick Steinhardt
Message 1 of 2 in “history: initialize rev_info in cmd_history_reword()”
  1. history: initialize rev_info in cmd_history_reword()René Scharfe, Mar 8, 2026
  2. Patrick SteinhardtMar 10, 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.