summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-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;