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

[PATCH 2/2] am: plug FILE * leak in split_mail_conv()

From
Junio C Hamano <gitster@pobox.com>
Date
May 11, 2016, 23:35 UTC
Message-ID
<20160511233546.13090-2-gitster@pobox.com>
In-Reply-To
<20160511233546.13090-1-gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/am.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/am.c b/builtin/am.c
index f1a84c6..a373928 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -761,9 +761,11 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state,
 		mail = mkpath("%s/%0*d", state->dir, state->prec, i + 1);
 
 		out = fopen(mail, "w");
-		if (!out)
+		if (!out) {
+			fclose(in);
 			return error(_("could not open '%s' for writing: %s"),
 					mail, strerror(errno));
+		}
 
 		ret = fn(out, in, keep_cr);
 
-- 
2.8.2-679-g91c6421
Previous: Junio C HamanoNext: Jeff King
Message 2 of 8 in “am: plug small memory leak when split_mail_stgit_series() fails”
  1. 1/2 am: plug small memory leak when split_mail_stgit_series() failsJunio C Hamano, May 11, 2016
  2. 2/2 am: plug FILE * leak in split_mail_conv()Junio C Hamano, May 11, 2016
  3. Jeff KingMay 12, 2016
  4. Mikael MagnussonMay 12, 2016
  5. Jeff KingMay 12, 2016
  6. Eric WongMay 12, 2016
  7. Jeff KingMay 12, 2016
  8. Junio C HamanoMay 12, 2016

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.