Skip to content

Commit 5c14bd6

Browse files
committed
Merge branch 'rs/am-builtin-leakfix'
Leakfix. * rs/am-builtin-leakfix: am: release strbuf after use in split_mail_mbox()
2 parents e87f9fc + 1b09073 commit 5c14bd6

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
@@ -708,6 +708,7 @@ static int split_mail_mbox(struct am_state *state, const char **paths,
708708
{
709709
struct child_process cp = CHILD_PROCESS_INIT;
710710
struct strbuf last = STRBUF_INIT;
711+
int ret;
711712

712713
cp.git_cmd = 1;
713714
argv_array_push(&cp.args, "mailsplit");
@@ -721,13 +722,16 @@ static int split_mail_mbox(struct am_state *state, const char **paths,
721722
argv_array_push(&cp.args, "--");
722723
argv_array_pushv(&cp.args, paths);
723724

724-
if (capture_command(&cp, &last, 8))
725-
return -1;
725+
ret = capture_command(&cp, &last, 8);
726+
if (ret)
727+
goto exit;
726728

727729
state->cur = 1;
728730
state->last = strtol(last.buf, NULL, 10);
729731

730-
return 0;
732+
exit:
733+
strbuf_release(&last);
734+
return ret ? -1 : 0;
731735
}
732736

733737
/**

0 commit comments

Comments
 (0)