defend against bad bytecode

Closes #2107
This commit is contained in:
Matthew Flatt 2018-06-01 06:03:33 +08:00
parent ba874ebe14
commit 2cfd65e972

View File

@ -3078,11 +3078,13 @@ static Scheme_Object *read_compact(CPort *port, int use_stack)
pf = (Scheme_Prefix *)read_compact(port, 0);
}
if ((pos < 0) || (pos >= pf->num_slots))
if (!SAME_TYPE(SCHEME_TYPE(pf), scheme_prefix_type) || (pos < 0) || (pos >= pf->num_slots))
scheme_ill_formed_code(port);
flags &= SCHEME_TOPLEVEL_FLAGS_MASK;
i = ((pos << SCHEME_LOG_TOPLEVEL_FLAG_MASK) | flags);
if ((i < 0) || (i >= (pf->num_slots * (SCHEME_TOPLEVEL_FLAGS_MASK + 1))))
scheme_ill_formed_code(port);
tl = ((Scheme_Object **)pf->a[pf->num_slots-1])[i];
if (!tl) {