提交 e9813620 编写于 作者: R Rich Felker

fix wcsncpy writing past end of buffer

上级 19892bf0
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
wchar_t *wcsncpy(wchar_t *d, const wchar_t *s, size_t n) wchar_t *wcsncpy(wchar_t *d, const wchar_t *s, size_t n)
{ {
wchar_t *a = d; wchar_t *a = d;
while (n && (*d++ = *s++)) n--; for (; n && (*d = *s); n--, d++, s++);
wmemset(d, 0, n); wmemset(d, 0, n);
return a; return a;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册