diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2014-07-11 21:04:18 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2014-07-11 21:04:18 +0000 |
commit | 5d2b02e4488800ac59b6fbb22b4a23253de2da79 (patch) | |
tree | c7a84959371b191f5f36e0141db1f78fb0ab44e4 /usr.bin/m4 | |
parent | bfa032b27025066b750630818f12686f06a9ca65 (diff) |
better error handling in mkstemp/unlink/fdopen logic.
from Doug Hogan <doug@acyclic.org>
okay miod@
Diffstat (limited to 'usr.bin/m4')
-rw-r--r-- | usr.bin/m4/eval.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c index a11895e48a2..b4a72686b82 100644 --- a/usr.bin/m4/eval.c +++ b/usr.bin/m4/eval.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eval.c,v 1.72 2014/04/28 12:34:11 espie Exp $ */ +/* $OpenBSD: eval.c,v 1.73 2014/07/11 21:04:17 espie Exp $ */ /* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */ /* @@ -817,11 +817,10 @@ dodiv(int n) if (outfile[n] == NULL) { char fname[] = _PATH_DIVNAME; - if ((fd = mkstemp(fname)) < 0 || - (outfile[n] = fdopen(fd, "w+")) == NULL) - err(1, "%s: cannot divert", fname); - if (unlink(fname) == -1) - err(1, "%s: cannot unlink", fname); + if ((fd = mkstemp(fname)) < 0 || + unlink(fname) == -1 || + (outfile[n] = fdopen(fd, "w+")) == NULL) + err(1, "%s: cannot divert", fname); } active = outfile[n]; } |