diff options
author | kib <kib@FreeBSD.org> | 2009-09-05 13:32:05 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2009-09-05 13:32:05 +0000 |
commit | 167fe991d621ce6db09bc99459ec094fb403a8df (patch) | |
tree | 55d50a1459e0c3651b3bb38a3616b09e933f50d4 | |
parent | b620cd133b1e05adf2a40923154dcb2e712ade46 (diff) | |
download | FreeBSD-src-167fe991d621ce6db09bc99459ec094fb403a8df.zip FreeBSD-src-167fe991d621ce6db09bc99459ec094fb403a8df.tar.gz |
Handle zero size for posix_memalign. Return NULL or unique address
according to the 'V' option.
PR: standards/138307
MFC after: 1 week
-rw-r--r-- | lib/libc/stdlib/malloc.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 270d641..b56b003 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -5320,6 +5320,15 @@ posix_memalign(void **memptr, size_t alignment, size_t size) goto RETURN; } + if (size == 0) { + if (opt_sysv == false) + size = 1; + else { + result = NULL; + ret = 0; + goto RETURN; + } + } result = ipalloc(alignment, size); } |