# [PATCH] history: initialize rev_info in cmd_history_reword()

2 messages from 2026-03-08 to 2026-03-10. Participants: René Scharfe, Patrick Steinhardt.
Thread: https://gitlist.dev/t/65166

## René Scharfe, 2026-03-08 09:57

Subject: [PATCH] history: initialize rev_info in cmd_history_reword()
Message-ID: <b0b8633f-be95-48eb-8244-d0e3f1a7be72@web.de>
URL: https://gitlist.dev/e/b0b8633f-be95-48eb-8244-d0e3f1a7be72%40web.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

```

## Patrick Steinhardt, 2026-03-10 12:16

Subject: Re: [PATCH] history: initialize rev_info in cmd_history_reword()
Message-ID: <abALiEDdNXCTzVux@pks.im>
URL: https://gitlist.dev/e/abALiEDdNXCTzVux%40pks.im
In-Reply-To: <b0b8633f-be95-48eb-8244-d0e3f1a7be72@web.de>

```
On Sun, Mar 08, 2026 at 10:57:02AM +0100, René Scharfe wrote:
> 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.

This looks obviously correct to me. Thanks!

Patrick

```
