bisect: fix memory leak when returning best element
When `find_bisection()` returns a single list entry, it leaks the other entries. Move the to-be-returned item to the front and free the remainder. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
7c117184d7
commit
f4e45cb3eb
6
bisect.c
6
bisect.c
@ -399,8 +399,12 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
|
||||
/* Do the real work of finding bisection commit. */
|
||||
best = do_find_bisection(list, nr, weights, find_all);
|
||||
if (best) {
|
||||
if (!find_all)
|
||||
if (!find_all) {
|
||||
list->item = best->item;
|
||||
free_commit_list(list->next);
|
||||
best = list;
|
||||
best->next = NULL;
|
||||
}
|
||||
*reaches = weight(best);
|
||||
}
|
||||
free(weights);
|
||||
|
Loading…
Reference in New Issue
Block a user