summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-09-05 13:32:05 +0000
committerkib <kib@FreeBSD.org>2009-09-05 13:32:05 +0000
commit167fe991d621ce6db09bc99459ec094fb403a8df (patch)
tree55d50a1459e0c3651b3bb38a3616b09e933f50d4 /lib
parentb620cd133b1e05adf2a40923154dcb2e712ade46 (diff)
downloadFreeBSD-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
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/malloc.c9
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);
}
OpenPOWER on IntegriCloud