Skip to content

Commit 6261489

Browse files
committed
Merge branch 'ly/sequencer-rearrange-leakfix'
Leakfix. * ly/sequencer-rearrange-leakfix: sequencer: fix memory leak if `todo_list_rearrange_squash()` failed
2 parents 2426a21 + 044511f commit 6261489

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sequencer.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6594,6 +6594,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
65946594
char **subjects;
65956595
struct commit_todo_item commit_todo;
65966596
struct todo_item *items = NULL;
6597+
int ret = 0;
65976598

65986599
init_commit_todo_item(&commit_todo);
65996600
/*
@@ -6624,8 +6625,8 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
66246625
}
66256626

66266627
if (is_fixup(item->command)) {
6627-
clear_commit_todo_item(&commit_todo);
6628-
return error(_("the script was already rearranged."));
6628+
ret = error(_("the script was already rearranged."));
6629+
goto cleanup;
66296630
}
66306631

66316632
repo_parse_commit(the_repository, item->commit);
@@ -6727,6 +6728,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
67276728
todo_list->items = items;
67286729
}
67296730

6731+
cleanup:
67306732
free(next);
67316733
free(tail);
67326734
for (i = 0; i < todo_list->nr; i++)
@@ -6736,7 +6738,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
67366738

67376739
clear_commit_todo_item(&commit_todo);
67386740

6739-
return 0;
6741+
return ret;
67406742
}
67416743

67426744
int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)

0 commit comments

Comments
 (0)