summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-11-20 14:39:34 +0100
committerJunio C Hamano <gitster@pobox.com>2024-11-21 00:23:41 +0100
commitcfb8a0da55fec9619e4e5b1e9b211ef85e3c9cb3 (patch)
tree2ee19b327de346097fb695287215f4e94ee4a2cd
parentbisect: fix leaking `current_bad_oid` (diff)
downloadgit-cfb8a0da55fec9619e4e5b1e9b211ef85e3c9cb3.tar.xz
git-cfb8a0da55fec9619e4e5b1e9b211ef85e3c9cb3.zip
bisect: fix multiple leaks in `bisect_next_all()`
There are multiple leaks in `bisect_next_all()`. For one we don't free the `tried` commit list. Second, one of the branches uses a direct return instead of jumping to the cleanup code. Fix these by freeing the commit list and converting the return to a goto. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--bisect.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bisect.c b/bisect.c
index 6dbc22f84f..04e9a63f11 100644
--- a/bisect.c
+++ b/bisect.c
@@ -1031,7 +1031,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
{
struct strvec rev_argv = STRVEC_INIT;
struct rev_info revs = REV_INFO_INIT;
- struct commit_list *tried;
+ struct commit_list *tried = NULL;
int reaches = 0, all = 0, nr, steps;
enum bisect_error res = BISECT_OK;
struct object_id *bisect_rev;
@@ -1098,7 +1098,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
if (oideq(bisect_rev, current_bad_oid)) {
res = error_if_skipped_commits(tried, current_bad_oid);
if (res)
- return res;
+ goto cleanup;
printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
term_bad);
@@ -1132,6 +1132,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
res = bisect_checkout(bisect_rev, no_checkout);
cleanup:
+ free_commit_list(tried);
release_revisions(&revs);
strvec_clear(&rev_argv);
return res;