[PATCH 1/2] msvcrt: Write memory forward in memset.
Rémi Bernon
rbernon at codeweavers.com
Thu Oct 21 03:44:29 CDT 2021
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 at codeweavers.com>
---
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;
}
}
--
2.33.0
More information about the wine-devel
mailing list