diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2009-06-11 12:57:38 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2009-06-11 12:57:38 +0000 |
commit | 660a416c99ea6f75a43954873f4ced76e5b8f925 (patch) | |
tree | 6f05b9018b146f22d43e23ec1d41519b245c0c1a /lib/libc | |
parent | 5008875f08ba2f4e5d297a6a25878ef545501ba6 (diff) |
don't use freelist if it overruns; use heap memory instead not
trying to allocate large blocks from bss memory pool in this case.
problem reported by Maksymilian Arciemowicz. ok otto@, millert@
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gdtoa/misc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/gdtoa/misc.c b/lib/libc/gdtoa/misc.c index b3ce7c9b8a4..6fd48e65192 100644 --- a/lib/libc/gdtoa/misc.c +++ b/lib/libc/gdtoa/misc.c @@ -55,7 +55,7 @@ Balloc #endif ACQUIRE_DTOA_LOCK(0); - if ( (rv = freelist[k]) !=0) { + if (k <= Kmax && (rv = freelist[k]) !=0) { freelist[k] = rv->next; } else { @@ -65,7 +65,7 @@ Balloc #else len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) /sizeof(double); - if (pmem_next - private_mem + len <= PRIVATE_mem) { + if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) { rv = (Bigint*)pmem_next; pmem_next += len; } @@ -89,6 +89,10 @@ Bfree #endif { if (v) { + if (v->k > Kmax) { + free(v); + return; + } ACQUIRE_DTOA_LOCK(0); v->next = freelist[v->k]; freelist[v->k] = v; |