aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dir.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index b2dfb69eb..b68750450 100644
--- a/dir.c
+++ b/dir.c
@@ -965,6 +965,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;
}
}