about summary refs log tree commit diff
path: root/malloc/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r--malloc/malloc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 09085e81ad..86f25d5184 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -822,6 +822,10 @@ do {                                                                          \
    computed. */
 
 
+/* Macro to set errno.  */
+#ifndef __set_errno
+# define __set_errno(val) errno = (val)
+#endif
 
 /* On some platforms we can compile internal, not exported functions better.
    Let the environment provide a macro and define it to be empty if it
@@ -1264,7 +1268,8 @@ static void      free_atfork();
 #define request2size(req, nb) \
  ((nb = (req) + (SIZE_SZ + MALLOC_ALIGN_MASK)),\
   ((long)nb <= 0 || nb < (INTERNAL_SIZE_T) (req) \
-   ? 1 : ((nb < (MINSIZE + MALLOC_ALIGN_MASK) \
+   ? (__set_errno (ENOMEM), 1) \
+   : ((nb < (MINSIZE + MALLOC_ALIGN_MASK) \
 	   ? (nb = MINSIZE) : (nb &= ~MALLOC_ALIGN_MASK)), 0)))
 
 /* Check if m has acceptable alignment */