Skip to contentSkip to conversation

history: initialize rev_info in cmd_history_reword()

PATCH In review René Scharfe 2 participants 2 messages Mar 8 – Mar 10

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 history: initialize rev_info in cmd_history_reword()

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.

---
 builtin/history.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
builtin/history.c +1 -1
index 1cf6c668cf..88822a184f 100644
@@ -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);
Signature · 1 line
2.53.0
#1 lore raw
Quoted 5 lines · René Scharfe

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