summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-12-27 11:16:22 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-12-27 11:16:23 -0800
commit5c14bd6175531a31b35f62ff8f1619eff38b06d1 (patch)
treee1e67c80f7095f771d9fbcac9d2fa46c96d7a286
parentMerge branch 'es/worktree-checkout-hook' (diff)
parentam: release strbuf after use in split_mail_mbox() (diff)
downloadtgif-5c14bd6175531a31b35f62ff8f1619eff38b06d1.tar.xz
Merge branch 'rs/am-builtin-leakfix'
Leakfix. * rs/am-builtin-leakfix: am: release strbuf after use in split_mail_mbox()
-rw-r--r--builtin/am.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/builtin/am.c b/builtin/am.c
index 3d98e52085..06b824518f 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;
}
/**