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

[PATCH] --walk-reflogs: do not crash with cyclic reflog ancestry

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 20, 2007, 21:28 UTC
Message-ID
<Pine.LNX.4.63.0701202227500.22628@wbgn013.biozentrum.uni-wuerzburg.de>

Since you can reset --hard to any revision you already had, when traversing the reflog ancestry, we may not free() the commit buffer.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 builtin-log.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index f3cff13..13a3f9b 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -50,8 +50,11 @@ static int cmd_log_walk(struct rev_info *rev)
 	prepare_revision_walk(rev);
 	while ((commit = get_revision(rev)) != NULL) {
 		log_tree_commit(rev, commit);
-		free(commit->buffer);
-		commit->buffer = NULL;
+		if (!rev->reflog_info) {
+			/* we allow cycles in reflog ancestry */
+			free(commit->buffer);
+			commit->buffer = NULL;
+		}
 		free_commit_list(commit->parents);
 		commit->parents = NULL;
 	}
-- 
1.5.0.rc1.g956c1-dirty
Message 1 of 1 in “--walk-reflogs: do not crash with cyclic reflog ancestry”
  1. --walk-reflogs: do not crash with cyclic reflog ancestryJohannes Schindelin, Jan 20, 2007

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.