Index: uspace/app/bdsh/compl.c
===================================================================
--- uspace/app/bdsh/compl.c	(revision 9be9c4dfa6546c6f2da92b12273ac723bee9af42)
+++ uspace/app/bdsh/compl.c	(revision 1e591c859dbe8a3ec5ca64521376979da364cef5)
@@ -67,4 +67,6 @@
 	/** Pointer inside list of directories */
 	const char **path;
+	/** If not @c NULL, should be freed in the end. */
+	const char **path_list;
 	/** Current open directory */
 	DIR *dir;
@@ -163,14 +165,15 @@
 		}
 		*cstart += rpath_sep + 1 - prefix;
-//		printf("cstart=%zu\n", *cstart);
 		free(prefix);
 
-//		printf("\ncs->prefix='%s', dirname='%s'\n", cs->prefix, dirname);
-
-		static const char *dlist2[2];
-		dlist2[0] = dirname;
-		dlist2[1] = NULL;
-		cs->path = dlist2;
-		/* XXX dirname won't be freed */
+		cs->path_list = malloc(sizeof(char *) * 2);
+		if (cs->path_list == NULL) {
+			retval = ENOMEM;
+			goto error;
+		}
+		cs->path_list[0] = dirname;
+		cs->path_list[1] = NULL;
+		cs->path = cs->path_list;
+
 	} else if (cs->is_command) {
 		/* Command without path */
@@ -193,4 +196,13 @@
 	/* Error cleanup */
 
+	if (cs != NULL && cs->path_list != NULL) {
+		size_t i = 0;
+		while (cs->path_list[i] != NULL) {
+			free(cs->path_list[i]);
+			++i;
+		}
+		free(cs->path_list);
+	}
+
 	if (cs != NULL && cs->prefix != NULL)
 		free(cs->prefix);
@@ -271,8 +283,6 @@
 
 			/* If it was the last one, we are done */
-			if (cs->dir == NULL) {
-				cs->path = NULL;
+			if (cs->dir == NULL)
 				break;
-			}
 
 			/* Read next directory entry */
@@ -322,4 +332,13 @@
 	compl_t *cs = (compl_t *) state;
 
+	if (cs->path_list != NULL) {
+		size_t i = 0;
+		while (cs->path_list[i] != NULL) {
+			free(cs->path_list[i]);
+			++i;
+		}
+		free(cs->path_list);
+	}
+
 	if (cs->last_compl != NULL)
 		free(cs->last_compl);
