Coverity CID 1755: Add fts_close() in traverse.
This commit is contained in:
parent
a6ee606509
commit
7e2f55514f
13
bin/ls/ls.c
13
bin/ls/ls.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ls.c,v 1.58 2005/10/26 02:24:22 jschauma Exp $ */
|
||||
/* $NetBSD: ls.c,v 1.59 2006/03/22 16:20:34 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: ls.c,v 1.58 2005/10/26 02:24:22 jschauma Exp $");
|
||||
__RCSID("$NetBSD: ls.c,v 1.59 2006/03/22 16:20:34 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -385,15 +385,17 @@ traverse(int argc, char *argv[], int options)
|
||||
{
|
||||
FTS *ftsp;
|
||||
FTSENT *p, *chp;
|
||||
int ch_options;
|
||||
int ch_options, error;
|
||||
|
||||
if ((ftsp =
|
||||
fts_open(argv, options, f_nosort ? NULL : mastercmp)) == NULL)
|
||||
err(EXIT_FAILURE, NULL);
|
||||
|
||||
display(NULL, fts_children(ftsp, 0));
|
||||
if (f_listdir)
|
||||
if (f_listdir) {
|
||||
fts_close(ftsp);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If not recursing down this tree and don't need stat info, just get
|
||||
@ -435,6 +437,9 @@ traverse(int argc, char *argv[], int options)
|
||||
(void)fts_set(ftsp, p, FTS_SKIP);
|
||||
break;
|
||||
}
|
||||
error = errno;
|
||||
fts_close(ftsp);
|
||||
errno = error;
|
||||
if (errno)
|
||||
err(EXIT_FAILURE, "fts_read");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user