summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-04-14 16:35:41 +0000
committerJim Meyering <jim@meyering.net>2006-04-14 16:35:41 +0000
commit47d0eb8722aeaff8b3a9b229ad58a4f46add0754 (patch)
tree27521b3a1293eb164fb0414fec73e60727982390 /lib
parent8085d02998442d1e77f3c855f4a96d6793e028f9 (diff)
downloadcoreutils-47d0eb8722aeaff8b3a9b229ad58a4f46add0754.tar.xz
(fts_open): Don't allocate parent if *argv==NULL. Patch from glibc.
Diffstat (limited to 'lib')
-rw-r--r--lib/fts.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/fts.c b/lib/fts.c
index e9896cdf8..2f017be54 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -273,7 +273,8 @@ fts_open (char * const *argv,
register FTS *sp;
register FTSENT *p, *root;
register size_t nitems;
- FTSENT *parent, *tmp = NULL; /* pacify gcc */
+ FTSENT *parent = NULL;
+ FTSENT *tmp = NULL; /* pacify gcc */
size_t len;
/* Options check. */
@@ -341,9 +342,11 @@ fts_open (char * const *argv,
}
/* Allocate/initialize root's parent. */
- if ((parent = fts_alloc(sp, "", 0)) == NULL)
- goto mem2;
- parent->fts_level = FTS_ROOTPARENTLEVEL;
+ if (*argv != NULL) {
+ if ((parent = fts_alloc(sp, "", 0)) == NULL)
+ goto mem2;
+ parent->fts_level = FTS_ROOTPARENTLEVEL;
+ }
/* Allocate/initialize root(s). */
for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) {