summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorPeter Valchev <pvalchev@cvs.openbsd.org>2006-05-30 19:43:28 +0000
committerPeter Valchev <pvalchev@cvs.openbsd.org>2006-05-30 19:43:28 +0000
commit2fd248c516077c997c2b56cdc8562bee55a3d7c6 (patch)
tree448979a575f3286aa8430f7054ce907975e3ad86 /usr.bin
parent6c3c5988fb408caa1cf44bebd650835bbbafdf8b (diff)
avoid double fclose(), from coverity/NetBSD; ok otto
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/vi/ex/ex_write.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/vi/ex/ex_write.c b/usr.bin/vi/ex/ex_write.c
index 7f9970f2783..9ab12e14306 100644
--- a/usr.bin/vi/ex/ex_write.c
+++ b/usr.bin/vi/ex/ex_write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_write.c,v 1.8 2006/03/11 06:52:00 ray Exp $ */
+/* $OpenBSD: ex_write.c,v 1.9 2006/05/30 19:43:27 pvalchev Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -355,14 +355,17 @@ ex_writefp(sp, name, fp, fm, tm, nlno, nch, silent)
S_ISREG(sb.st_mode) && fsync(fileno(fp)))
goto err;
- if (fclose(fp))
+ if (fclose(fp)) {
+ fp = NULL;
goto err;
+ }
rval = 0;
if (0) {
err: if (!F_ISSET(sp->ep, F_MULTILOCK))
msgq_str(sp, M_SYSERR, name, "%s");
- (void)fclose(fp);
+ if (fp != NULL)
+ (void)fclose(fp);
rval = 1;
}