summaryrefslogtreecommitdiff
path: root/builtin/am.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-04-24 05:07:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-04-24 05:07:56 (GMT)
commitf9096db54b29ed17afc6e3393f159ea55142b14c (patch)
tree250cf5594f21f55a19c00b16559a9c3a221013b0 /builtin/am.c
parenta507115e29690e831fedb060cfb50cef9e0f7514 (diff)
parentfa1912c89a72fbd94591f4f5d522e5867ffe9bb6 (diff)
downloadgit-f9096db54b29ed17afc6e3393f159ea55142b14c.zip
git-f9096db54b29ed17afc6e3393f159ea55142b14c.tar.gz
git-f9096db54b29ed17afc6e3393f159ea55142b14c.tar.bz2
Merge branch 'rs/misc-cppcheck-fixes'
Various small fixes. * rs/misc-cppcheck-fixes: server-info: avoid calling fclose(3) twice in update_info_file() files_for_each_reflog_ent_reverse(): close stream and free strbuf on error am: close stream on error, but not stdin
Diffstat (limited to 'builtin/am.c')
-rw-r--r--builtin/am.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin/am.c b/builtin/am.c
index f7a7a97..805f56c 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);