aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2021-04-28 03:57:39 +0200
committerBen Hutchings <ben@decadent.org.uk>2021-04-28 04:43:03 +0200
commit7f6626d12daa2f1efd9953d1f4ba2065348dc5cd (patch)
treefaa996aea336292caae3ad64f87b86567a5be822
parent8e88e0aafb402e11c61b9e2e377406afdb42f69e (diff)
downloadklibc-7f6626d12daa2f1efd9953d1f4ba2065348dc5cd.tar.gz
[klibc] malloc: Set errno on failure
malloc() is specified to set errno = ENOMEM on failure, so do that. Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--usr/klibc/malloc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/usr/klibc/malloc.c b/usr/klibc/malloc.c
index 413b7337be95c..bb57c9f6ffd34 100644
--- a/usr/klibc/malloc.c
+++ b/usr/klibc/malloc.c
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <sys/mman.h>
#include <assert.h>
+#include <errno.h>
#include "malloc.h"
/* Both the arena list and the free memory list are double linked
@@ -169,6 +170,7 @@ void *malloc(size_t size)
#endif
if (fp == (struct free_arena_header *)MAP_FAILED) {
+ errno = ENOMEM;
return NULL; /* Failed to get a block */
}