Index: fts.c
===================================================================
--- fts.c	(revision 19170)
+++ fts.c	(working copy)
@@ -1018,16 +1018,10 @@
   size_t len;
 
   /*
-   * The file name is a variable length array and no stat structure is
-   * necessary if the user has set the nostat bit.  Allocate the FTSENT
-   * structure, the file name and the stat structure in one chunk, but
-   * be careful that the stat structure is reasonably aligned.  Since the
-   * fts_name field is declared to be of size 1, the fts_name pointer is
-   * namelen + 2 before the first possible address of the stat structure.
+   * The file name is a variable length array. Allocate the FTSENT
+   * structure.
    */
   len = sizeof (FTSENT) + namelen;
-  if (!ISSET (FTS_NOSTAT))
-    len += sizeof (struct stat);
   if ((p = malloc (len)) == NULL)
     return (NULL);
 
@@ -1035,7 +1029,18 @@
   memmove (p->fts_name, name, namelen + 1);
 
   if (!ISSET (FTS_NOSTAT))
-    p->fts_statp = (struct stat *) (p->fts_name + namelen + 2);
+  {
+    if ((p->fts_statp = malloc(sizeof(struct stat))) == NULL)
+    {
+      free(p);
+      return NULL;
+    }
+  }
+  else
+  {
+    p->fts_statp = NULL;
+  }
+
   p->fts_namelen = namelen;
   p->fts_path = sp->fts_path;
   p->fts_errno = 0;
@@ -1056,6 +1061,8 @@
   while ((p = head))
     {
       head = head->fts_link;
+      if (p->fts_statp)
+        free (p->fts_statp);
       free (p);
     }
 }
