Browse Source

fix return value of wmemcmp for extreme wchar_t values

analogous to the bug in wcscmp and wcsncmp that was fixed in commit
07616721f1fa6cb215ffbef23441cae80412484f.
Rich Felker 1 year ago
parent
commit
b928c7234f
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/string/wmemcmp.c

+ 1 - 1
src/string/wmemcmp.c

@@ -3,5 +3,5 @@
 int wmemcmp(const wchar_t *l, const wchar_t *r, size_t n)
 {
 	for (; n && *l==*r; n--, l++, r++);
-	return n ? *l-*r : 0;
+	return n ? (*l < *r ? -1 : *l > *r) : 0;
 }