musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/string/wcscmp.c
AgeCommit message (Collapse)AuthorLines
2023年02月12日fix return value of wcs{,n}cmp for extreme wchar_t values Gabriel Ravier-1/+1
As a result of using simple subtraction to implement the return values for wcscmp and wcsncmp, integer overflow can occur (producing undefined behavior, and in practice, a wrong comparison result). This does not occur for meaningful character values (21-bit range) but the functions are specified to work on arbitrary wchar_t arrays. This patch replaces the subtraction with a little bit of code that orders the characters correctly, returning -1 if the character from the first string is smaller than the one from the second, 0 if they are equal and 1 if the character from the first string is larger than the one from the second.
2011年02月12日initial check-in, version 0.5.0 v0.5.0 Rich Felker-0/+7
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月07日 22:14:38 +0000

AltStyle によって変換されたページ (->オリジナル) /