diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-04-23 22:07:56 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-04-23 22:07:56 -0700 |
commit | f9096db54b29ed17afc6e3393f159ea55142b14c (patch) | |
tree | 250cf5594f21f55a19c00b16559a9c3a221013b0 /builtin | |
parent | Merge branch 'jk/snprintf-cleanups' (diff) | |
parent | server-info: avoid calling fclose(3) twice in update_info_file() (diff) | |
download | tgif-f9096db54b29ed17afc6e3393f159ea55142b14c.tar.xz |
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')
-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); |