]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(fts_open): Don't allocate parent if *argv==NULL. Patch from glibc.
authorJim Meyering <jim@meyering.net>
Fri, 14 Apr 2006 16:35:41 +0000 (16:35 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 14 Apr 2006 16:35:41 +0000 (16:35 +0000)
lib/fts.c

index e9896cdf8b5db104cb1f93466bf71b6fe277b4d7..2f017be54a493a26a933a21efa533fbee70fce20 100644 (file)
--- 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) {