diff options
author | delphij <delphij@FreeBSD.org> | 2010-03-13 00:15:06 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2010-03-13 00:15:06 +0000 |
commit | 5da11ddf693c5029d76eeb1217745631d90b7181 (patch) | |
tree | 672d5f163c49eb5e3a20085370141a95a8c7edd7 /lib/libc/string/strlen.c | |
parent | 13b8d0250999c3444c159ddf9ef56d78c4edbd02 (diff) | |
download | FreeBSD-src-5da11ddf693c5029d76eeb1217745631d90b7181.zip FreeBSD-src-5da11ddf693c5029d76eeb1217745631d90b7181.tar.gz |
Correct bugs fixed but not merged from my own tree.
Pointy hat to: delphij
MFC after: 1 month
Diffstat (limited to 'lib/libc/string/strlen.c')
-rw-r--r-- | lib/libc/string/strlen.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/string/strlen.c b/lib/libc/string/strlen.c index 0302ace..2bc1f2b 100644 --- a/lib/libc/string/strlen.c +++ b/lib/libc/string/strlen.c @@ -99,14 +99,15 @@ strlen(const char *str) lp = (const unsigned long *)((uintptr_t)str & ~LONGPTR_MASK); va = (*lp - mask01); vb = ((~*lp) & mask80); + lp++; if (va & vb) /* Check if we have \0 in the first part */ - for (p = str; (uintptr_t)p & LONGPTR_MASK; p++) + for (p = str; p < (const char *)lp; p++) if (*p == '\0') return (p - str); /* Scan the rest of the string using word sized operation */ - for (lp = (const unsigned long *)p; ; lp++) { + for (; ; lp++) { va = (*lp - mask01); vb = ((~*lp) & mask80); if (va & vb) { |