Skip to content

Commit 0bc6180

Browse files
committed
Merge branch 'nd/maint-relative' into maint
* nd/maint-relative: get_cwd_relative(): do not misinterpret root path
2 parents 3f14246 + fbbb4e1 commit 0bc6180

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
@@ -965,6 +965,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
965965
case '/':
966966
return cwd + 1;
967967
default:
968+
/*
969+
* dir can end with a path separator when it's root
970+
* directory. Return proper prefix in that case.
971+
*/
972+
if (dir[-1] == '/')
973+
return cwd;
968974
return NULL;
969975
}
970976
}

0 commit comments

Comments
 (0)