Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Mar 2009 03:30:21 +0000 (UTC)
From:      David Schultz <das@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189348 - head/lib/libc/gen
Message-ID:  <200903040330.n243ULV5030287@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: das
Date: Wed Mar  4 03:30:21 2009
New Revision: 189348
URL: http://svn.freebsd.org/changeset/base/189348

Log:
  Fix a file descriptor leak in fts_child().
  
  Obtained from:	NetBSD

Modified:
  head/lib/libc/gen/fts.c

Modified: head/lib/libc/gen/fts.c
==============================================================================
--- head/lib/libc/gen/fts.c	Wed Mar  4 03:22:03 2009	(r189347)
+++ head/lib/libc/gen/fts.c	Wed Mar  4 03:30:21 2009	(r189348)
@@ -570,8 +570,10 @@ fts_children(sp, instr)
 	if ((fd = _open(".", O_RDONLY, 0)) < 0)
 		return (NULL);
 	sp->fts_child = fts_build(sp, instr);
-	if (fchdir(fd))
+	if (fchdir(fd)) {
+		(void)_close(fd);
 		return (NULL);
+	}
 	(void)_close(fd);
 	return (sp->fts_child);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903040330.n243ULV5030287>