This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PATCH: New 64 bit wcscmp implementation
I think there's still one overflow case left:
> +int
> +simple_wcscmp (const wchar_t *s1, const wchar_t *s2)
> +{
> + wchar_t c1, c2;
> + do
> + {
> + c1 = *s1++;
> + c2 = *s2++;
> + if (c1 == L'\0')
> + return c1 - c2;
Here, if c2 is WCHAR_MIN then c1 - c2 will overflow (most probably
resulting in the return value ending up as negative when it should be
positive. The same applies to the main C implementation of wcscmp.
I think changing the if condition to "c2 == L'\0'" will suffice to avoid
the overflow possibility here.
--
Joseph S. Myers
joseph@codesourcery.com