mirror of
https://github.com/git/git.git
synced 2026-03-19 05:00:08 +01:00
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 <jrnieder@gmail.com> Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
6eed493d2d
commit
09457d2867
6
line.c
6
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 */
|
||||
|
||||
Reference in New Issue
Block a user