diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-05-27 13:59:07 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-05-27 13:59:07 -0700 |
| commit | 6261489cdba61715ee9e0716d7a8a7fc63c53e49 (patch) | |
| tree | 2adbf6b9d4cc8f1c5a00e9d9e4c40aceb4d87e18 | |
| parent | 2426a213888823d7f535eca4e04b65413b1e4169 (diff) | |
| parent | 044511f889b1989840339a322f84e50dfa3bf6e0 (diff) | |
| download | git-6261489cdba61715ee9e0716d7a8a7fc63c53e49.tar.gz | |
Merge branch 'ly/sequencer-rearrange-leakfix'
Leakfix.
* ly/sequencer-rearrange-leakfix:
sequencer: fix memory leak if `todo_list_rearrange_squash()` failed
| -rw-r--r-- | sequencer.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sequencer.c b/sequencer.c index 4edf66fb28..eacede6bf2 100644 --- a/sequencer.c +++ b/sequencer.c @@ -6594,6 +6594,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) char **subjects; struct commit_todo_item commit_todo; struct todo_item *items = NULL; + int ret = 0; init_commit_todo_item(&commit_todo); /* @@ -6624,8 +6625,8 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) } if (is_fixup(item->command)) { - clear_commit_todo_item(&commit_todo); - return error(_("the script was already rearranged.")); + ret = error(_("the script was already rearranged.")); + goto cleanup; } repo_parse_commit(the_repository, item->commit); @@ -6727,6 +6728,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) todo_list->items = items; } +cleanup: free(next); free(tail); for (i = 0; i < todo_list->nr; i++) @@ -6736,7 +6738,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) clear_commit_todo_item(&commit_todo); - return 0; + return ret; } int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) |
