mirror of
https://github.com/devkitPro/wut.git
synced 2026-03-21 17:34:47 -05:00
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:
parent
6d7b8fdda6
commit
fefde021b9
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user