fix overrun (n essentially ignored) in wcsncmp

bug report and solution by Richard Pennington
This commit is contained in:
Rich Felker 2012-05-26 18:04:17 -04:00
commit 054ba18599

View file

@ -2,6 +2,6 @@
int wcsncmp(const wchar_t *l, const wchar_t *r, size_t n)
{
for (; n && *l==*r && *l && *r; l++, r++);
for (; n && *l==*r && *l && *r; n--, l++, r++);
return n ? *l - *r : 0;
}