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

[PATCH] am: release strbuf after use in split_mail_mbox()

From
René Scharfe <l.s.r@web.de>
Date
Dec 7, 2017, 20:20 UTC
Message-ID
<ad0af192-1bd4-eee2-d6e8-2f1776e87428@web.de>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 builtin/am.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/builtin/am.c b/builtin/am.c
index 02853b3e05..1ac044da2e 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -708,6 +708,7 @@ static int split_mail_mbox(struct am_state *state, const char **paths,
 {
 	struct child_process cp = CHILD_PROCESS_INIT;
 	struct strbuf last = STRBUF_INIT;
+	int ret;
 
 	cp.git_cmd = 1;
 	argv_array_push(&cp.args, "mailsplit");
@@ -721,13 +722,16 @@ static int split_mail_mbox(struct am_state *state, const char **paths,
 	argv_array_push(&cp.args, "--");
 	argv_array_pushv(&cp.args, paths);
 
-	if (capture_command(&cp, &last, 8))
-		return -1;
+	ret = capture_command(&cp, &last, 8);
+	if (ret)
+		goto exit;
 
 	state->cur = 1;
 	state->last = strtol(last.buf, NULL, 10);
 
-	return 0;
+exit:
+	strbuf_release(&last);
+	return ret ? -1 : 0;
 }
 
 /**
-- 
2.15.1
Next: Jeff King
Message 1 of 2 in “am: release strbuf after use in split_mail_mbox()”
  1. am: release strbuf after use in split_mail_mbox()René Scharfe, Dec 7, 2017
  2. Jeff KingDec 7, 2017

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.