git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] am: release strbuf after use in split_mail_mbox()
@ 2017-12-07 20:20 René Scharfe
  2017-12-07 21:20 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2017-12-07 20:20 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-07 21:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-07 20:20 [PATCH] am: release strbuf after use in split_mail_mbox() René Scharfe
2017-12-07 21:20 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).