Skip to content

Commit 1b09073

Browse files
rscharfegitster
authored andcommitted
am: release strbuf after use in split_mail_mbox()
Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e97a5e7 commit 1b09073

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

builtin/am.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ static int split_mail_mbox(struct am_state *state, const char **paths, int keep_
702702
{
703703
struct child_process cp = CHILD_PROCESS_INIT;
704704
struct strbuf last = STRBUF_INIT;
705+
int ret;
705706

706707
cp.git_cmd = 1;
707708
argv_array_push(&cp.args, "mailsplit");
@@ -713,13 +714,16 @@ static int split_mail_mbox(struct am_state *state, const char **paths, int keep_
713714
argv_array_push(&cp.args, "--");
714715
argv_array_pushv(&cp.args, paths);
715716

716-
if (capture_command(&cp, &last, 8))
717-
return -1;
717+
ret = capture_command(&cp, &last, 8);
718+
if (ret)
719+
goto exit;
718720

719721
state->cur = 1;
720722
state->last = strtol(last.buf, NULL, 10);
721723

722-
return 0;
724+
exit:
725+
strbuf_release(&last);
726+
return ret ? -1 : 0;
723727
}
724728

725729
/**

0 commit comments

Comments
 (0)