diff --git a/src/system/libroot/posix/malloc_debug/guarded_heap.cpp b/src/system/libroot/posix/malloc_debug/guarded_heap.cpp index 051d913b14..f0727cbe44 100644 --- a/src/system/libroot/posix/malloc_debug/guarded_heap.cpp +++ b/src/system/libroot/posix/malloc_debug/guarded_heap.cpp @@ -966,7 +966,7 @@ memalign(size_t alignment, size_t size) extern "C" void* malloc(size_t size) { - return memalign(0, size); + return memalign(size >= 8 ? 8 : 0, size); } @@ -987,7 +987,7 @@ realloc(void* address, size_t newSize) } if (address == NULL) - return memalign(0, newSize); + return memalign(size >= 8 ? 8 : 0, newSize); return guarded_heap_realloc(address, newSize); } diff --git a/src/system/libroot/posix/malloc_debug/heap.cpp b/src/system/libroot/posix/malloc_debug/heap.cpp index 074cada0e0..699de22014 100644 --- a/src/system/libroot/posix/malloc_debug/heap.cpp +++ b/src/system/libroot/posix/malloc_debug/heap.cpp @@ -1465,7 +1465,7 @@ heap_realloc(heap_allocator *heap, void *address, void **newAddress, newSize -= sizeof(addr_t) + sizeof(heap_leak_check_info); // if not, allocate a new chunk of memory - *newAddress = memalign(0, newSize); + *newAddress = memalign(newSize >= 8 ? 8 : 0, newSize); if (*newAddress == NULL) { // we tried but it didn't work out, but still the operation is done return B_OK; @@ -1937,7 +1937,7 @@ malloc(size_t size) if (sUseGuardPage) return heap_debug_malloc_with_guard_page(size); - return memalign(0, size); + return memalign(size >= 8 ? 8 : 0, size); } @@ -1978,7 +1978,7 @@ void * realloc(void *address, size_t newSize) { if (address == NULL) - return memalign(0, newSize); + return memalign(newSize >= 8 ? 8 : 0, newSize); if (newSize == 0) { free(address);