Skip to content

Commit

Permalink
--walk-reflogs: do not crash with cyclic reflog ancestry
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jan 21, 2007
1 parent 40ab7c3 commit a6c7306
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a6c7306

Please sign in to comment.