summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormartynas <martynas@openbsd.org>2009-06-11 12:57:37 +0000
committermartynas <martynas@openbsd.org>2009-06-11 12:57:37 +0000
commitf4514f752a57a92bd51b86e87657bebae61c5043 (patch)
treea6ea6641567e23ba4aea41b7b2249d8e951acfe1
parenttab indent SO_RDOMAIN, like all the other SO_* defines. (diff)
downloadwireguard-openbsd-f4514f752a57a92bd51b86e87657bebae61c5043.tar.xz
wireguard-openbsd-f4514f752a57a92bd51b86e87657bebae61c5043.zip
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@
-rw-r--r--lib/libc/gdtoa/misc.c8
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;