chars: don't persist when only one of the compared sequences is invalid
Persisting might lead to count 'n' reaching zero, which would mean that the needle has matched, which is wrong when one of the strings contains an invalid or incomplete multibyte sequence.master
parent
d80109dd5e
commit
e38e2c634b
|
@ -530,6 +530,9 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||||
if (*s1 != *s2)
|
if (*s1 != *s2)
|
||||||
return (unsigned char)*s1 - (unsigned char)*s2;
|
return (unsigned char)*s1 - (unsigned char)*s2;
|
||||||
|
|
||||||
|
if (bad1 != bad2)
|
||||||
|
return (bad1 ? 1 : -1);
|
||||||
|
|
||||||
s1++; s2++; n--;
|
s1++; s2++; n--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue