From 880b6df674a3bd372a4b440e671f5ab7d67d846a Mon Sep 17 00:00:00 2001 From: rtr Date: Sun, 19 Mar 2006 05:01:48 +0000 Subject: [PATCH] avoid double fclose() coverity 2577 / run 6 --- usr.bin/vi/ex/ex_write.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/usr.bin/vi/ex/ex_write.c b/usr.bin/vi/ex/ex_write.c index 96deec068027..f9077abede23 100644 --- a/usr.bin/vi/ex/ex_write.c +++ b/usr.bin/vi/ex/ex_write.c @@ -1,4 +1,4 @@ -/* $NetBSD: ex_write.c,v 1.11 2005/06/02 04:25:16 lukem Exp $ */ +/* $NetBSD: ex_write.c,v 1.12 2006/03/19 05:01:48 rtr Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -16,7 +16,7 @@ #if 0 static const char sccsid[] = "@(#)ex_write.c 10.30 (Berkeley) 7/12/96"; #else -__RCSID("$NetBSD: ex_write.c,v 1.11 2005/06/02 04:25:16 lukem Exp $"); +__RCSID("$NetBSD: ex_write.c,v 1.12 2006/03/19 05:01:48 rtr Exp $"); #endif #endif /* not lint */ @@ -360,14 +360,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 (NULL != fp) + (void)fclose(fp); rval = 1; }