Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/cp Fix fd leak in error case. Found by cppcheck.



details:   https://anonhg.NetBSD.org/src/rev/0f0ff5fef0e4
branches:  trunk
changeset: 760410:0f0ff5fef0e4
user:      wiz <wiz%NetBSD.org@localhost>
date:      Tue Jan 04 10:35:10 2011 +0000

description:
Fix fd leak in error case. Found by cppcheck.

diffstat:

 bin/cp/utils.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r be1a65caf2dc -r 0f0ff5fef0e4 bin/cp/utils.c
--- a/bin/cp/utils.c    Tue Jan 04 10:32:34 2011 +0000
+++ b/bin/cp/utils.c    Tue Jan 04 10:35:10 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utils.c,v 1.37 2010/12/21 20:56:01 christos Exp $ */
+/* $NetBSD: utils.c,v 1.38 2011/01/04 10:35:10 wiz Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utils.c    8.3 (Berkeley) 4/1/94";
 #else
-__RCSID("$NetBSD: utils.c,v 1.37 2010/12/21 20:56:01 christos Exp $");
+__RCSID("$NetBSD: utils.c,v 1.38 2011/01/04 10:35:10 wiz Exp $");
 #endif
 #endif /* not lint */
 
@@ -117,6 +117,7 @@
                        lstat(to.p_path, &sb) : stat(to.p_path, &sb);
                if (sval == -1) {
                        warn("stat: %s", to.p_path);
+                       (void)close(from_fd);
                        return (1);
                }
 



Home | Main Index | Thread Index | Old Index