From a22f5d5175df5c42ec86d2c2db250edf1f64084c Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Fri, 1 Mar 2019 16:40:59 -0800 Subject: Make aligned_alloc match the standard. Jemalloc does not verify that the size parameter is a multiple of alignment. Fix this since it only went into P. Fix the unit tests, and fix malloc debug/malloc hooks to handle this new restrictive behavior. Bug: 126944692 Test: Ran bionic unit tests. Test: Ran bionic unit tests with malloc hooks enabled (no new tests fail). Test: Ran bionic unit tests with malloc debug enabled (no new tests fail). Test: Ran malloc debug unit tests. Change-Id: I4d50785928815679c781ca729f998454d76b9192 --- libc/malloc_hooks/malloc_hooks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc/malloc_hooks/malloc_hooks.cpp') diff --git a/libc/malloc_hooks/malloc_hooks.cpp b/libc/malloc_hooks/malloc_hooks.cpp index f7bdd563a..715a6295b 100644 --- a/libc/malloc_hooks/malloc_hooks.cpp +++ b/libc/malloc_hooks/malloc_hooks.cpp @@ -176,7 +176,7 @@ int hooks_mallopt(int param, int value) { void* hooks_aligned_alloc(size_t alignment, size_t size) { if (__memalign_hook != nullptr && __memalign_hook != default_memalign_hook) { - if (!powerof2(alignment)) { + if (!powerof2(alignment) || (size % alignment) != 0) { errno = EINVAL; return nullptr; } -- cgit v1.2.3