summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc-simple
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdlib/malloc-simple')
-rw-r--r--libc/stdlib/malloc-simple/alloc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c
index 14f384632..a3c068a5b 100644
--- a/libc/stdlib/malloc-simple/alloc.c
+++ b/libc/stdlib/malloc-simple/alloc.c
@@ -42,8 +42,10 @@ void *malloc(size_t size)
result = mmap((void *) 0, size + sizeof(size_t), PROT_READ | PROT_WRITE,
MMAP_FLAGS, 0, 0);
- if (result == MAP_FAILED)
+ if (result == MAP_FAILED) {
+ __set_errno(ENOMEM);
return 0;
+ }
* (size_t *) result = size;
return(result + sizeof(size_t));
}