From 27eb7787636cb7d6bb19b0289524e19eb599bec1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 1 Oct 2016 18:41:41 -0700 Subject: Check for overflow in static slot counter. * struct.c (make_struct_type, static_slot_ens_rec): Throw an error if there are too many static slots. --- struct.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/struct.c b/struct.c index 35f5fc45..837a1a0e 100644 --- a/struct.c +++ b/struct.c @@ -316,7 +316,10 @@ val make_struct_type(val name, val super, } if (sl >= STATIC_SLOT_BASE) - uw_throwf(error_s, lit("~a: too many slots"), self, nao); + uw_throwf(error_s, lit("~a: too many instance slots"), self, nao); + + if (stsl >= NUM_MAX) + uw_throwf(error_s, lit("~a: too many static slots"), self, nao); } stsl -= STATIC_SLOT_BASE; @@ -969,6 +972,10 @@ static val static_slot_ens_rec(val stype, val sym, val newval, return newval; } else { struct stslot null_ptr = { nil, 0, 0, nil }; + + if (st->nstslots >= NUM_MAX) + uw_throwf(error_s, lit("~a: too many static slots"), self, nao); + st->stslot = coerce(struct stslot *, chk_manage_vec(coerce(mem_t *, st->stslot), st->nstslots, st->nstslots + 1, -- cgit v1.2.3