Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/lpr/lpc Fix fd leak in error cases. Found by cppcheck.



details:   https://anonhg.NetBSD.org/src/rev/05542ee39635
branches:  trunk
changeset: 760397:05542ee39635
user:      wiz <wiz%NetBSD.org@localhost>
date:      Tue Jan 04 09:43:39 2011 +0000

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

diffstat:

 usr.sbin/lpr/lpc/cmds.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 166e4d3018c8 -r 05542ee39635 usr.sbin/lpr/lpc/cmds.c
--- a/usr.sbin/lpr/lpc/cmds.c   Tue Jan 04 09:42:21 2011 +0000
+++ b/usr.sbin/lpr/lpc/cmds.c   Tue Jan 04 09:43:39 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.22 2009/07/13 19:05:41 roy Exp $    */
+/*     $NetBSD: cmds.c,v 1.23 2011/01/04 09:43:39 wiz Exp $    */
 /*
  * Copyright (c) 1983, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -36,7 +36,7 @@
 #if 0
 static char sccsid[] = "@(#)cmds.c     8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: cmds.c,v 1.22 2009/07/13 19:05:41 roy Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.23 2011/01/04 09:43:39 wiz Exp $");
 #endif
 #endif /* not lint */
 
@@ -563,6 +563,8 @@
        if (fd < 0 || flock(fd, LOCK_EX) < 0) {
                printf("\tcannot create status file\n");
                seteuid(uid);
+               if (fd >= 0)
+                       (void)close(fd);
                return;
        }
        seteuid(uid);



Home | Main Index | Thread Index | Old Index