aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/path.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index a46ac4f..4c6e1f7 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2601,8 +2601,7 @@ getwd (char *buf)
}
/* chdir: POSIX 5.2.1.1 */
-extern "C"
-int
+extern "C" int
chdir (const char *dir)
{
syscall_printf ("dir %s", dir);
@@ -2642,7 +2641,7 @@ chdir (const char *dir)
of dots > 2 here instead of returning an error code. Counts of dots
<= 2 are already eliminated by normalize_posix_path. */
char *last_slash = strrchr (pathbuf, '/');
- if (last_slash && strspn (last_slash + 1, ".") == strlen (last_slash + 1))
+ if (last_slash > pathbuf && strspn (last_slash + 1, ".") == strlen (last_slash + 1))
*last_slash = '\0';
free (cwd_posix);
cwd_posix = strdup (pathbuf);