From 2fd248c516077c997c2b56cdc8562bee55a3d7c6 Mon Sep 17 00:00:00 2001 From: Peter Valchev Date: Tue, 30 May 2006 19:43:28 +0000 Subject: avoid double fclose(), from coverity/NetBSD; ok otto --- usr.bin/vi/ex/ex_write.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'usr.bin') 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; } -- cgit v1.2.3