summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index 852e60f..38f3e3e 100644
--- a/dir.c
+++ b/dir.c
@@ -1033,6 +1033,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
case '/':
return cwd + 1;
default:
+ /*
+ * dir can end with a path separator when it's root
+ * directory. Return proper prefix in that case.
+ */
+ if (dir[-1] == '/')
+ return cwd;
return NULL;
}
}