From: Jim Meyering <[email protected]>
---
lib/fts.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/fts.c b/lib/fts.c
index 9e935ba..48919f7 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1229,7 +1229,6 @@ static FTSENT *
internal_function
fts_build (register FTS *sp, int type)
{
- register struct dirent *dp;
register FTSENT *p, *head;
register size_t nitems;
FTSENT *tail;
@@ -1352,9 +1351,14 @@ fts_build (register FTS *sp, int type)
/* Read the directory, attaching each entry to the `link' pointer. */
doadjust = false;
- for (head = tail = NULL, nitems = 0; cur->fts_dirp && (dp =
readdir(cur->fts_dirp));) {
+ head = NULL;
+ tail = NULL;
+ nitems = 0;
+ while (cur->fts_dirp) {
bool is_dir;
-
+ struct dirent *dp = readdir(cur->fts_dirp);
+ if (dp == NULL)
+ break;
if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
continue;
--
1.7.6.857.gf34cf