Module Name:    src
Committed By:   wiz
Date:           Tue Jan  4 09:43:39 UTC 2011

Modified Files:
        src/usr.sbin/lpr/lpc: cmds.c

Log Message:
Fix fd leak in error cases. Found by cppcheck.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/lpr/lpc/cmds.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/lpr/lpc/cmds.c
diff -u src/usr.sbin/lpr/lpc/cmds.c:1.22 src/usr.sbin/lpr/lpc/cmds.c:1.23
--- src/usr.sbin/lpr/lpc/cmds.c:1.22	Mon Jul 13 19:05:41 2009
+++ src/usr.sbin/lpr/lpc/cmds.c	Tue Jan  4 09:43:39 2011
@@ -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);

Reply via email to