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

[PATCH] Plug a memleak in builtin-revert

From
Alex Riesen <raa.lkml@gmail.com>
Date
Oct 28, 2008, 17:27 UTC
Message-ID
<20081028172733.GA7054@blimp.localdomain>

Probably happened when working around git_path's problem with returned buffer being reused.

---
 builtin-revert.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-revert.c b/builtin-revert.c
index 4725540..7483a7a 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -251,7 +251,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	int i, index_fd, clean;
 	char *oneline, *reencoded_message = NULL;
 	const char *message, *encoding;
-	const char *defmsg = xstrdup(git_path("MERGE_MSG"));
+	char *defmsg = xstrdup(git_path("MERGE_MSG"));
 	struct merge_options o;
 	struct tree *result, *next_tree, *base_tree, *head_tree;
 	static struct lock_file index_lock;
@@ -432,6 +432,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 		return execv_git_cmd(args);
 	}
 	free(reencoded_message);
+	free(defmsg);
 
 	return 0;
 }
-- 
1.6.0.3.549.gb475d
Message 1 of 1 in “Plug a memleak in builtin-revert”
  1. Plug a memleak in builtin-revertAlex Riesen, Oct 28, 2008

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.