fix wrong return value from wmemmove on forward copies

This commit is contained in:
Rich Felker
2013-02-21 23:19:18 -05:00
parent 8224bdbbed
commit 330fd96213

View File

@ -3,9 +3,10 @@
wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n) wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n)
{ {
wchar_t *d0 = d;
if ((size_t)(d-s) < n) if ((size_t)(d-s) < n)
while (n--) d[n] = s[n]; while (n--) d[n] = s[n];
else else
while (n--) *d++ = *s++; while (n--) *d++ = *s++;
return d; return d0;
} }