diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-07-13 08:35:45 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-07-13 08:35:45 +0000 |
commit | 55370e7dedf35051de90df8250a1e8bfdf89e32e (patch) | |
tree | 1b758b33983ed469519ca5ca43cffb26506e8159 /lib/libc/stdlib | |
parent | f366d8836695f62100f56335b119c42b0b0c0bf0 (diff) |
Fix two cases where malloc() returns NULL but does not set errno to ENOMEM.
ok tdeval@ henning@ millert@
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/malloc.c | 7 |
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 |