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

This commit is contained in:
Rich Felker 2011-06-29 19:26:30 -04:00
parent 47e72e10d5
commit f9ed11f3e1
1 changed files with 1 additions and 1 deletions

View File

@ -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)) {