in string::search(), don't call memchr() if ptr == NULL.

noticed when tbl started logging lots of assertion errors generated from my
local copy of libc which has (a modified) assert() tests throughout.
This commit is contained in:
lukem 1999-08-11 12:38:11 +00:00
parent e48f29e82b
commit 781a4dc195

View File

@ -270,7 +270,7 @@ void string::clear()
int string::search(char c) const
{
char *p = (char *)memchr(ptr, c, len);
char *p = ptr ? (char *)memchr(ptr, c, len) : NULL;
return p ? p - ptr : -1;
}