From 09457d28671e54015b6be308b5762fb207721dde Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Sat, 11 Sep 2010 23:10:57 +0200 Subject: [PATCH] log -L: do not free parents lists we might need again The parent rewriting code of 'git log -L' was too aggressive in freeing memory: assign_range_to_parent() will free the commit->parents field when it sees that a parent cannot pass off any blame (is a root commit in rewritten history). Its caller assign_parents_range() however will, upon finding the first parent that takes *full* blame for all ranges, rewind and reinstate all previous parents' line ranges and parent lists. This resurrects pointers to ranges that were freed in assign_range_to_parent() under some circumstances. Furthermore, we must not empty the parent lists either: the same rewind/reinstate code relies on them. Do both only if the commit was an ordinary (not merge or root) commit, in which case the merge code-path discussed here is never taken. Reported-by: Jonathan Nieder Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- line.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/line.c b/line.c index 63dd19a8c4..b0deafb70e 100644 --- a/line.c +++ b/line.c @@ -961,8 +961,10 @@ static int assign_range_to_parent(struct rev_info *rev, struct commit *c, * If there is no new ranges assigned to the parent, * we should mark it as a 'root' commit. */ - free(c->parents); - c->parents = NULL; + if (c->parents && !c->parents->next) { + free(c->parents); + c->parents = NULL; + } } /* and the ranges of current commit c is updated */