Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
am: close stream on error, but not stdin
author
René Scharfe
<l.s.r@web.de>
Sun, 16 Apr 2017 16:55:30 +0000
(18:55 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 17 Apr 2017 04:27:39 +0000
(21:27 -0700)
Avoid closing stdin, but do close an actual input file on error exit.
Found with Cppcheck.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
49800c9
)
diff --git
a/builtin/am.c
b/builtin/am.c
index 31fb60578f6caacfb376fe84938dda9432dcfc5a..172960094c573316de8ea02e1343519fe3ec36ad 100644
(file)
--- 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);