Module: wine Branch: master Commit: 7c046c7afd4253daa9cd8dbb6b2f466f128fecc9 URL: https://source.winehq.org/git/wine.git/?a=commit;h=7c046c7afd4253daa9cd8dbb6...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu Oct 21 10:44:29 2021 +0200
msvcrt: Write memory forward in memset.
Instead of going backward, which breaks the Linux kernel transparent huge pages allocation assumptions.
This can be reproduced by calling memset on large, newly allocated, memory regions.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/msvcrt/string.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index 5655fbfe68a..48d44d3b72e 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -2857,13 +2857,14 @@ void * __cdecl memcpy(void *dst, const void *src, size_t n)
static inline void memset_aligned_32(unsigned char *d, uint64_t v, size_t n) { - while (n >= 32) - { - *(uint64_t *)(d + n - 32) = v; - *(uint64_t *)(d + n - 24) = v; - *(uint64_t *)(d + n - 16) = v; - *(uint64_t *)(d + n - 8) = v; - n -= 32; + unsigned char *end = d + n; + while (d < end) + { + *(uint64_t *)(d + 0) = v; + *(uint64_t *)(d + 8) = v; + *(uint64_t *)(d + 16) = v; + *(uint64_t *)(d + 24) = v; + d += 32; } }