aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/common/get_path.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/common/get_path.c b/lib/common/get_path.c
index bdc6c3f..72ed1bd 100644
--- a/lib/common/get_path.c
+++ b/lib/common/get_path.c
@@ -15,8 +15,12 @@ char *sqfs_tree_node_get_path(const sqfs_tree_node_t *node)
char *str, *ptr;
size_t len = 0;
- if (node->parent == NULL)
+ if (node->parent == NULL) {
+ if (node->name[0] != '\0')
+ return strdup((const char *)node->name);
+
return strdup("/");
+ }
for (it = node; it != NULL && it->parent != NULL; it = it->parent) {
len += strlen((const char *)it->name) + 1;