diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-10-01 18:41:41 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-10-01 18:41:41 -0700 |
commit | 27eb7787636cb7d6bb19b0289524e19eb599bec1 (patch) | |
tree | 6cf7e07e6ff7539e2e58817090ca1c976125d5f5 | |
parent | 8beea6646701faf8d18be5e37dc216f18debad10 (diff) | |
download | txr-27eb7787636cb7d6bb19b0289524e19eb599bec1.tar.gz txr-27eb7787636cb7d6bb19b0289524e19eb599bec1.tar.bz2 txr-27eb7787636cb7d6bb19b0289524e19eb599bec1.zip |
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.
-rw-r--r-- | struct.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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, |