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

[PATCH] rerere: fix memory leak if rerere images can't be read

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Feb 23, 2010, 20:11 UTC
Message-ID
<1266955913-4943-1-git-send-email-bert.wesarg@googlemail.com>
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 rerere.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/rerere.c b/rerere.c
index d1d3e75..9ca4cb8 100644
--- a/rerere.c
+++ b/rerere.c
@@ -364,16 +364,17 @@ static int find_conflict(struct string_list *conflict)
 static int merge(const char *name, const char *path)
 {
 	int ret;
-	mmfile_t cur, base, other;
+	mmfile_t cur = {NULL, 0}, base = {NULL, 0}, other = {NULL, 0};
 	mmbuffer_t result = {NULL, 0};
 
 	if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0)
 		return 1;
 
+	ret = 1;
 	if (read_mmfile(&cur, rerere_path(name, "thisimage")) ||
 			read_mmfile(&base, rerere_path(name, "preimage")) ||
 			read_mmfile(&other, rerere_path(name, "postimage")))
-		return 1;
+		goto out;
 	ret = ll_merge(&result, path, &base, &cur, "", &other, "", 0);
 	if (!ret) {
 		FILE *f = fopen(path, "w");
@@ -387,6 +388,7 @@ static int merge(const char *name, const char *path)
 				     strerror(errno));
 	}
 
+out:
 	free(cur.ptr);
 	free(base.ptr);
 	free(other.ptr);
-- 
1.7.0.500.ge51cb
Next: Johannes Schindelin
Message 1 of 5 in “rerere: fix memory leak if rerere images can't be read”
  1. rerere: fix memory leak if rerere images can't be readBert Wesarg, Feb 23, 2010
  2. Johannes SchindelinFeb 23, 2010
  3. Bert WesargFeb 23, 2010
  4. Johannes SchindelinFeb 23, 2010
  5. Junio C HamanoFeb 23, 2010

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.