--walk-reflogs: do not crash with cyclic reflog ancestry
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Sat, 20 Jan 2007 21:28:16 +0000 (22:28 +0100)
committerJunio C Hamano <junkio@cox.net>
Sun, 21 Jan 2007 06:58:42 +0000 (22:58 -0800)
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>
builtin-log.c

index f3cff13edc80afad27b9f7930a0a736ba5aa6d16..13a3f9b25db3fb2746c21b2ce6327627c965c0ce 100644 (file)
@@ -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;
        }