Browse Source

posix_memalign should fail if size is not a multiple of sizeof(void *)

Rich Felker 14 years ago
parent
commit
f9ed11f3e1
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/malloc/posix_memalign.c

+ 1 - 1
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;
 	unsigned char *mem, *new, *end;
 	size_t header, footer;
 	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 (len > SIZE_MAX - align) return ENOMEM;
 
 
 	if (align <= 4*sizeof(size_t)) {
 	if (align <= 4*sizeof(size_t)) {