diff --git a/src/dir_import.c b/src/dir_import.c
index 48a9e8211725164e45debdf2a22b0c8d279b5e82..68c39fe5af7f59acb92c2438df1e6c72479b7bb6 100644
--- a/src/dir_import.c
+++ b/src/dir_import.c
@@ -431,10 +431,13 @@ static int itemdir(uint64_t dev) {
 
 
 static int iteminfo(struct dir **item, uint64_t dev, int isdir) {
-  static struct dir dir;
-  struct dir *tmp, *d = &dir;
+  static struct dir *dirbuf;
+  struct dir *tmp, *d;
   uint64_t iv;
 
+  if(!dirbuf)
+    dirbuf = malloc(sizeof(struct dir));
+  d = dirbuf;
   memset(d, 0, sizeof(struct dir));
   d->flags |= isdir ? FF_DIR : FF_FILE;
   d->dev = dev;
diff --git a/src/dirlist.c b/src/dirlist.c
index 50b90f0ab10492d846ce4c0df4b77f1567fd31de..893382cb54c0658bc1e5faaf933d792a95ed85b6 100644
--- a/src/dirlist.c
+++ b/src/dirlist.c
@@ -40,8 +40,7 @@ int    dirlist_sort_desc   = 1,
        dirlist_hidden      = 0;
 
 /* private state vars */
-static struct dir dirlist_parent_alloc;
-static struct dir *head, *head_real, *selected, *top = NULL;
+static struct dir *parent_alloc, *head, *head_real, *selected, *top = NULL;
 
 
 
@@ -206,14 +205,15 @@ void dirlist_open(struct dir *d) {
     head_real = head = dirlist_sort(head);
 
   /* set the reference to the parent dir */
-  dirlist_parent_alloc.flags &= ~FF_BSEL;
-  dirlist_parent_alloc.flags |= FF_DIR;
   if(d->parent) {
-    dirlist_parent = &dirlist_parent_alloc;
+    if(!parent_alloc)
+      parent_alloc = calloc(1, SDIRSIZE + 3);
+    dirlist_parent = parent_alloc;
     strcpy(dirlist_parent->name, "..");
     dirlist_parent->next = head;
     dirlist_parent->parent = d;
     dirlist_parent->sub = d;
+    dirlist_parent->flags = FF_DIR;
     head = dirlist_parent;
   } else
     dirlist_parent = NULL;
diff --git a/src/global.h b/src/global.h
index 4cd02e1a40a6a023ae23c160090fc93ccb3373fb..8c02461389d7fb8e642a84a8ad0bec598a4fd0fc 100644
--- a/src/global.h
+++ b/src/global.h
@@ -66,7 +66,7 @@ struct dir {
   struct dir *parent, *next, *prev, *sub, *hlnk;
   int items;
   unsigned char flags;
-  char name[3]; /* must be large enough to hold ".." */
+  char name[];
 };
 /* sizeof(total dir) = SDIRSIZE + strlen(name) = offsetof(struct dir, name) + strlen(name) + 1 */
 #define SDIRSIZE (offsetof(struct dir, name)+1)