]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cheri: malloc: align up without breaking capability in memalign
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 15 Mar 2022 09:54:59 +0000 (09:54 +0000)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 27 Oct 2022 13:46:53 +0000 (14:46 +0100)
malloc/malloc.c

index 062ca0dc0aa4b6cd6d60789542af7591966b9ff7..02df29d2ad8ab050d8e9f9f8a41d55278297baa6 100644 (file)
@@ -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;