diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/am.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin/am.c b/builtin/am.c index f7a7a971fb..805f56cec2 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -762,14 +762,18 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state, mail = mkpath("%s/%0*d", state->dir, state->prec, i + 1); out = fopen(mail, "w"); - if (!out) + if (!out) { + if (in != stdin) + fclose(in); return error_errno(_("could not open '%s' for writing"), mail); + } ret = fn(out, in, keep_cr); fclose(out); - fclose(in); + if (in != stdin) + fclose(in); if (ret) return error(_("could not parse patch '%s'"), *paths); |