[PATCH 14/17] sequencer.c: fix sequencer_continue() leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix a leak in the recent da1d63363f1 (rebase --merge: fix reflog when
continuing, 2022-10-12), per [1] the author was under the impression
that by calling "setenv()" the C library took possession of the
string, but we need to free() it.

As [1] also notes there's upcoming changes to do some larger rewrite
of these codepaths in sequencer.c, but let's first do this much
smaller and isolated leak fix.

1. https://lore.kernel.org/git/86699708-d631-fb49-482c-af27204a3570@xxxxxxxxxxxxx/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 sequencer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sequencer.c b/sequencer.c
index 14ca0af2ade..3095d0d2b3b 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -5069,10 +5069,12 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
 		previous_reflog_action = xstrdup(getenv(GIT_REFLOG_ACTION));
 		setenv(GIT_REFLOG_ACTION, reflog_message(opts, "continue", NULL), 1);
 		if (commit_staged_changes(r, opts, &todo_list)) {
+			free(previous_reflog_action);
 			res = -1;
 			goto release_todo_list;
 		}
 		setenv(GIT_REFLOG_ACTION, previous_reflog_action, 1);
+		free(previous_reflog_action);
 	} else if (!file_exists(get_todo_path(opts)))
 		return continue_single_pick(r, opts);
 	else if ((res = read_populate_todo(r, &todo_list, opts)))
-- 
2.38.0.1451.g86b35f4140a




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux