--walk-reflogs: do not crash with cyclic reflog ancestry
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> Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
Jan 20, 2007 at 22:28 UTC
a6c730644b7e1d35bd0d26962dbc978aa47d1863
1 file changed
+5
-2
builtin-log.c
+5
-2
@@ -50,8 +50,11 @@ static int cmd_log_walk(struct rev_info *rev)
50
prepare_revision_walk(rev);
51
while ((commit = get_revision(rev)) != NULL) {
52
log_tree_commit(rev, commit);
53
- free(commit->buffer);
54
- commit->buffer = NULL;
53
+ if (!rev->reflog_info) {
54
+ /* we allow cycles in reflog ancestry */
55
+ free(commit->buffer);
56
+ commit->buffer = NULL;
57
+ }
58
free_commit_list(commit->parents);
59
commit->parents = NULL;
60
}