summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-11-05 20:24:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-11-06 01:15:29 (GMT)
commitf4e45cb3eb6fad4570ff63eecb37bae8102992fc (patch)
tree6c5bcac21f03ec8d0af24dbd4a2704dcacd51c87
parent7c117184d7e3727d4240beb42148d106483d00b9 (diff)
downloadgit-f4e45cb3eb6fad4570ff63eecb37bae8102992fc.zip
git-f4e45cb3eb6fad4570ff63eecb37bae8102992fc.tar.gz
git-f4e45cb3eb6fad4570ff63eecb37bae8102992fc.tar.bz2
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>
-rw-r--r--bisect.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bisect.c b/bisect.c
index b194150..3756f12 100644
--- a/bisect.c
+++ b/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);