summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc-standard
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-04-02 12:06:00 +0000
committerMike Frysinger <vapier@gentoo.org>2007-04-02 12:06:00 +0000
commitc9210d381426332b9af4e7b01086dcea1fd49d05 (patch)
tree838b5a9ae2bc6761e7d64cb481a47b98c433b426 /libc/stdlib/malloc-standard
parentb612121d0d4b220041b43e591c802a82e028e34d (diff)
POSIX requires that errno be set whenever 0 is returned by malloc()
Diffstat (limited to 'libc/stdlib/malloc-standard')
-rw-r--r--libc/stdlib/malloc-standard/malloc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libc/stdlib/malloc-standard/malloc.c b/libc/stdlib/malloc-standard/malloc.c
index 85b5081e3..3253ebda6 100644
--- a/libc/stdlib/malloc-standard/malloc.c
+++ b/libc/stdlib/malloc-standard/malloc.c
@@ -826,7 +826,10 @@ void* malloc(size_t bytes)
void * retval;
#if !defined(__MALLOC_GLIBC_COMPAT__)
- if (!bytes) return NULL;
+ if (!bytes) {
+ __set_errno(ENOMEM);
+ return NULL;
+ }
#endif
__MALLOC_LOCK;