summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r--lib/libc/stdlib/malloc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index e1294732030..3ce107857a4 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -8,7 +8,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: malloc.c,v 1.56 2003/05/14 17:46:39 tdeval Exp $";
+static char rcsid[] = "$OpenBSD: malloc.c,v 1.57 2003/07/13 08:35:44 otto Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -387,6 +387,7 @@ map_pages(pages)
#ifdef MALLOC_EXTRA_SANITY
wrterror("(ES): overflow in map_pages fails\n");
#endif /* MALLOC_EXTRA_SANITY */
+ errno = ENOMEM;
return (NULL);
}
tail = result + pages;
@@ -838,8 +839,10 @@ imalloc(size)
if (suicide)
abort();
- if ((size + malloc_pagesize) < size) /* Check for overflow */
+ if ((size + malloc_pagesize) < size) { /* Check for overflow */
result = NULL;
+ errno = ENOMEM;
+ }
else if (size <= malloc_maxsize)
result = malloc_bytes(size);
else