Fix: char_traits::find needs to return nullptr if nothing was found.

This commit is contained in:
Michael Lutz 2023-11-03 00:40:17 +01:00
parent 7d4a91ef9e
commit c294eaacc1
1 changed files with 4 additions and 4 deletions

View File

@ -343,12 +343,12 @@ struct CaseInsensitiveCharTraits : public std::char_traits<char> {
return 0; return 0;
} }
static const char *find(const char *s, int n, char a) static const char *find(const char *s, size_t n, char a)
{ {
while (n-- > 0 && toupper(*s) != toupper(a)) { for (; n > 0; --n, ++s) {
++s; if (toupper(*s) == toupper(a)) return s;
} }
return s; return nullptr;
} }
}; };