diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c index 938dcb58c82a..73832e59ff18 100644 --- a/lib/libc/gen/fts-compat.c +++ b/lib/libc/gen/fts-compat.c @@ -747,7 +747,7 @@ mem1: saved_errno = errno; * state. */ if (ISSET(FTS_NOCHDIR)) { - if (cp - 1 > sp->fts_path) + if (len == sp->fts_pathlen) --cp; *cp = '\0'; } diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 938dcb58c82a..73832e59ff18 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -747,7 +747,7 @@ mem1: saved_errno = errno; * state. */ if (ISSET(FTS_NOCHDIR)) { - if (cp - 1 > sp->fts_path) + if (len == sp->fts_pathlen) --cp; *cp = '\0'; }