Skip to content

Commit cfb8a0d

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a13d4a1 commit cfb8a0d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

bisect.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
10311031
{
10321032
struct strvec rev_argv = STRVEC_INIT;
10331033
struct rev_info revs = REV_INFO_INIT;
1034-
struct commit_list *tried;
1034+
struct commit_list *tried = NULL;
10351035
int reaches = 0, all = 0, nr, steps;
10361036
enum bisect_error res = BISECT_OK;
10371037
struct object_id *bisect_rev;
@@ -1098,7 +1098,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
10981098
if (oideq(bisect_rev, current_bad_oid)) {
10991099
res = error_if_skipped_commits(tried, current_bad_oid);
11001100
if (res)
1101-
return res;
1101+
goto cleanup;
11021102
printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
11031103
term_bad);
11041104

@@ -1132,6 +1132,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
11321132

11331133
res = bisect_checkout(bisect_rev, no_checkout);
11341134
cleanup:
1135+
free_commit_list(tried);
11351136
release_revisions(&revs);
11361137
strvec_clear(&rev_argv);
11371138
return res;

0 commit comments

Comments
 (0)