Skip to content

Commit 20cb8e2

Browse files
committed
Merge branch 'nd/maint-relative'
* nd/maint-relative: get_cwd_relative(): do not misinterpret root path
2 parents b720c75 + fbbb4e1 commit 20cb8e2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

dir.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
10331033
case '/':
10341034
return cwd + 1;
10351035
default:
1036+
/*
1037+
* dir can end with a path separator when it's root
1038+
* directory. Return proper prefix in that case.
1039+
*/
1040+
if (dir[-1] == '/')
1041+
return cwd;
10361042
return NULL;
10371043
}
10381044
}

0 commit comments

Comments
 (0)