bisect: fix a regression causing a segfault
In7c117184d7
("bisect: fix off-by-one error in `best_bisection_sorted()`", 2017-11-05) the more careful logic dealing with freeing p->next in50e62a8e70
("rev-list: implement --bisect-all", 2007-10-22) was removed. Restore the more careful check to avoid segfaulting. Ideally this would come with a test case, but we don't have steps to reproduce this, only a backtrace from gdb pointing to this being the issue. Reported-by: Yasushi SHOJI <yasushi.shoji@gmail.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f4e45cb3eb
commit
2e9fdc795c
2
bisect.c
2
bisect.c
@ -229,8 +229,10 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n
|
|||||||
if (i < cnt - 1)
|
if (i < cnt - 1)
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
|
if (p) {
|
||||||
free_commit_list(p->next);
|
free_commit_list(p->next);
|
||||||
p->next = NULL;
|
p->next = NULL;
|
||||||
|
}
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
free(array);
|
free(array);
|
||||||
return list;
|
return list;
|
||||||
|
Reference in New Issue
Block a user