[klibc] [klibc:master] malloc: Set errno on failure
klibc-bot for Ben Hutchings
ben at decadent.org.uk
Thu Apr 29 17:00:18 PDT 2021
Commit-ID: 7f6626d12daa2f1efd9953d1f4ba2065348dc5cd
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=7f6626d12daa2f1efd9953d1f4ba2065348dc5cd
Author: Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Wed, 28 Apr 2021 03:57:39 +0200
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Wed, 28 Apr 2021 04:43:03 +0200
[klibc] malloc: Set errno on failure
malloc() is specified to set errno = ENOMEM on failure, so do that.
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/klibc/malloc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/usr/klibc/malloc.c b/usr/klibc/malloc.c
index 413b7337..bb57c9f6 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 */
}
More information about the klibc
mailing list