From f9ed11f3e1337d6bac6298db1d66d4f27bb59f6b Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 29 Jun 2011 19:26:30 -0400 Subject: [PATCH] posix_memalign should fail if size is not a multiple of sizeof(void *) --- src/malloc/posix_memalign.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/malloc/posix_memalign.c b/src/malloc/posix_memalign.c index ef86260d..2ae928c8 100644 --- a/src/malloc/posix_memalign.c +++ b/src/malloc/posix_memalign.c @@ -11,7 +11,7 @@ int posix_memalign(void **res, size_t align, size_t len) unsigned char *mem, *new, *end; size_t header, footer; - if ((align & -align) != align) return EINVAL; + if ((align & -align & -sizeof(void *)) != align) return EINVAL; if (len > SIZE_MAX - align) return ENOMEM; if (align <= 4*sizeof(size_t)) { -- 2.25.1