am: release strbuf after use in split_mail_mbox()
Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Dec 7, 2017 at 21:20 UTC
1b09073514085c51bbd2884122af60a45b24db5d
1 file changed
+7
-3
builtin/am.c
+7
-3
@@ -702,6 +702,7 @@ static int split_mail_mbox(struct am_state *state, const char **paths, int keep_
702
{
703
struct child_process cp = CHILD_PROCESS_INIT;
704
struct strbuf last = STRBUF_INIT;
705
+ int ret;
706
707
cp.git_cmd = 1;
708
argv_array_push(&cp.args, "mailsplit");
@@ -713,13 +714,16 @@ static int split_mail_mbox(struct am_state *state, const char **paths, int keep_
714
argv_array_push(&cp.args, "--");
715
argv_array_pushv(&cp.args, paths);
716
716
- if (capture_command(&cp, &last, 8))
717
- return -1;
717
+ ret = capture_command(&cp, &last, 8);
718
+ if (ret)
719
+ goto exit;
720
721
state->cur = 1;
722
state->last = strtol(last.buf, NULL, 10);
723
722
- return 0;
724
+exit:
725
+ strbuf_release(&last);
726
+ return ret ? -1 : 0;
727
}
728
729
/**