diff options
| author | 2006-11-22 18:59:50 +0000 | |
|---|---|---|
| committer | 2006-11-22 18:59:50 +0000 | |
| commit | f6a23d7a22c7aeef46691200ba51513860ce3d0f (patch) | |
| tree | 60873f070f8a2c2f0b0bfa3af27d6dbc9ff7bba4 /sys/kern/kern_malloc.c | |
| parent | fix some warning messages and comments in parse_date(); ok henning@ (diff) | |
| download | wireguard-openbsd-f6a23d7a22c7aeef46691200ba51513860ce3d0f.tar.xz wireguard-openbsd-f6a23d7a22c7aeef46691200ba51513860ce3d0f.zip | |
If M_CANFAIL is set and the malloc() size is to big
return NULL instead of panic()'ing.
ok pedro@, deraadt@
Diffstat (limited to 'sys/kern/kern_malloc.c')
| -rw-r--r-- | sys/kern/kern_malloc.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 040ea782114..3652ec639d3 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_malloc.c,v 1.63 2006/09/30 14:31:28 mickey Exp $ */ +/* $OpenBSD: kern_malloc.c,v 1.64 2006/11/22 18:59:50 thib Exp $ */ /* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */ /* @@ -151,8 +151,13 @@ malloc(unsigned long size, int type, int flags) return ((void *) va); #endif - if (size > 65535 * PAGE_SIZE) - panic("malloc: allocation too large"); + if (size > 65535 * PAGE_SIZE) { + if (flags & M_CANFAIL) + return (NULL); + else + panic("malloc: allocation too large"); + } + indx = BUCKETINDX(size); kbp = &bucket[indx]; s = splvm(); |
