git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/5] sequencer: always free "struct replay_opts"

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Apr 18, 2024, 13:14 UTC
Message-ID
<9d96300b1c8ce3ab88affa571b2e29cd5b52160d.1713445918.git.phillip.wood@dunelm.org.uk>
In-Reply-To
<cover.1713445918.git.phillip.wood@dunelm.org.uk>
From: Phillip Wood <phillip.wood@dunelm.org.uk>

sequencer_post_commit_cleanup() initializes an instance of "struct replay_opts" but does not call replay_opts_release(). Currently this does not leak memory because the code paths called don't allocate any of the struct members. That will change in the next commit so add call to replay_opts_release() to prevent a memory leak in "git commit" that breaks all of the leak free tests.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 sequencer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index f49a871ac06..e4146b4cdfa 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2823,12 +2823,14 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
 			NULL, REF_NO_DEREF);
 
 	if (!need_cleanup)
-		return;
+		goto out;
 
 	if (!have_finished_the_last_pick())
-		return;
+		goto out;
 
 	sequencer_remove_state(&opts);
+out:
+	replay_opts_release(&opts);
 }
 
 static void todo_list_write_total_nr(struct todo_list *todo_list)
-- 
2.44.0.661.ge68cfcc6c2f
Previous: Phillip WoodNext: Phillip Wood
Message 2 of 10 in “rebase -m: fix --signoff with conflicts”
  1. 0/5 rebase -m: fix --signoff with conflictsPhillip Wood, Apr 18, 2024
  2. 1/5 sequencer: always free "struct replay_opts"Phillip Wood, Apr 18, 2024
  3. 2/5 sequencer: start removing private fields from public APIPhillip Wood, Apr 18, 2024
  4. Junio C HamanoApr 18, 2024
  5. 3/5 sequencer: move current fixups to private contextPhillip Wood, Apr 18, 2024
  6. Junio C HamanoApr 18, 2024
  7. 4/5 sequencer: store commit message in private contextPhillip Wood, Apr 18, 2024
  8. Junio C HamanoApr 18, 2024
  9. 5/5 rebase -m: fix --signoff with conflictsPhillip Wood, Apr 18, 2024
  10. Junio C HamanoApr 18, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.