wutmalloc: Fix memalign to ensure the size is aligned (#196)

This fixes situations that can arise in places such as FSReadFile/FSWriteFile, in which buffer sizes need to be aligned to 0x40; otherwise heap corruptions could happen when multithreading.
This commit is contained in:
Maschell 2022-02-12 20:49:16 +01:00 committed by GitHub
parent 6d7b8fdda6
commit fefde021b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,7 +69,7 @@ _calloc_r(struct _reent *r, size_t num, size_t size)
void *
_memalign_r(struct _reent *r, size_t align, size_t size)
{
return MEMAllocFromDefaultHeapEx(size, align);
return MEMAllocFromDefaultHeapEx((size + align - 1) & ~(align - 1), align);
}
struct mallinfo _mallinfo_r(struct _reent *r)