From d898e3f5ca14eeb41f2e3d211b649afbd4e27860 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 28 Apr 2021 03:57:39 +0200 Subject: [PATCH] [klibc] malloc: Set errno on failure Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=7f6626d12daa2f1efd9953d1f4ba2065348dc5cd malloc() is specified to set errno = ENOMEM on failure, so do that. Signed-off-by: Ben Hutchings Gbp-Pq: Name 0035-klibc-malloc-Set-errno-on-failure.patch --- usr/klibc/malloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr/klibc/malloc.c b/usr/klibc/malloc.c index 413b733..bb57c9f 100644 --- a/usr/klibc/malloc.c +++ b/usr/klibc/malloc.c @@ -8,6 +8,7 @@ #include #include #include +#include #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 */ } -- 2.30.2