diff options
-rw-r--r-- | lib/dirtree.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/dirtree.c b/lib/dirtree.c index cc5d0545..736c2db5 100644 --- a/lib/dirtree.c +++ b/lib/dirtree.c @@ -87,8 +87,10 @@ char *dirtree_path(struct dirtree *node, int *plen) char *path; int ii, ll, len; - if (!node->parent) return xstrdup(node->name); ll = len = plen ? *plen : 0; + if (!node->parent) { + return strcpy(path = xzalloc(strlen(node->name)+ll+1), node->name); + } for (nn = node; nn; nn = nn->parent) if ((ii = strlen(nn->name))) len += ii+1-(nn->name[ii-1]=='/'); if (plen) *plen = len; |