From 0ca08c2c7b100baaebbd60744110102611f9b895 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Tue, 15 Mar 2022 09:54:59 +0000 Subject: [PATCH] cheri: malloc: align up without breaking capability in memalign --- malloc/malloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 062ca0dc0aa..02df29d2ad8 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -4982,8 +4982,7 @@ _int_memalign (mstate av, size_t alignment, size_t bytes) we can move to the next aligned spot -- we've allocated enough total room so that this is always possible. */ - brk = (char *) mem2chunk (((unsigned long) (m + alignment - 1)) & - - ((signed long) alignment)); + brk = (char *) mem2chunk (m + alignment - ((unsigned long) (m) % alignment)); if ((unsigned long) (brk - (char *) (p)) < MINSIZE) brk += alignment; -- 2.47.2