diff --git a/fs/fs.c b/fs/fs.c index c9226f9..a5efdd1 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -158,8 +158,8 @@ path = freep = xstrdup(_pathname); - if (*path == '/') - outpath = xstrdup("/"); + if (*path == '/' || !strcmp(cwd, "/")) + outpath = xstrdup(""); else outpath = __canonicalize_path(cwd, level + 1); @@ -212,6 +212,11 @@ out: free(freep); + if (!*outpath) { + free(outpath); + outpath = xstrdup("/"); + } + return outpath; }