From: Szabolcs Nagy Date: Tue, 15 Mar 2022 09:54:59 +0000 (+0000) Subject: cheri: malloc: align up without breaking capability in memalign X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4064e7a4fc027aef0f023dc93fe436a512b1aaf9;p=thirdparty%2Fglibc.git cheri: malloc: align up without breaking capability in memalign --- 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;