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

[PATCH 1/5] revert: free msg in format_todo()

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Oct 22, 2011, 19:13 UTC
Message-ID
<1319310826-508-2-git-send-email-artagnon@gmail.com>
In-Reply-To
<1319310826-508-1-git-send-email-artagnon@gmail.com>

Memory allocated to the fields of msg by get_message() isn't freed. This is potentially a big leak, because fresh memory is allocated to store the commit message for each commit. Fix this using free_message().

Reported-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/revert.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/builtin/revert.c b/builtin/revert.c
index 87df70e..a6f2ea7 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -689,6 +689,7 @@ static int format_todo(struct strbuf *buf, struct commit_list *todo_list,
 		if (get_message(cur->item, &msg))
 			return error(_("Cannot get commit message for %s"), sha1_abbrev);
 		strbuf_addf(buf, "%s %s %s\n", action_str, sha1_abbrev, msg.subject);
+		free_message(&msg);
 	}
 	return 0;
 }
-- 
1.7.6.351.gb35ac.dirty
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 2 of 7 in “Sequencer fixups mini-series”
  1. 0/5 Sequencer fixups mini-seriesRamkumar Ramachandra, Oct 22, 2011
  2. 1/5 revert: free msg in format_todo()Ramkumar Ramachandra, Oct 22, 2011
  3. 2/5 revert: simplify getting commit subject in format_todo()Ramkumar Ramachandra, Oct 22, 2011
  4. 3/5 revert: make commit subjects in insn sheet optionalRamkumar Ramachandra, Oct 22, 2011
  5. 4/5 revert: allow mixed pick and revert instructionsRamkumar Ramachandra, Oct 22, 2011
  6. 5/5 revert: simplify communicating command-line argumentsRamkumar Ramachandra, Oct 22, 2011
  7. sequencer: factor code out of revert builtinRamkumar Ramachandra, Oct 23, 2011

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.