[gamecode] Add statement bounds checking

Statements can be bounds checked in the one place (jump calculation),
but memory accesses cannot as they can be used in lea instructions which
should never cause an exception (unless one of lea's operands is OOB).
This commit is contained in:
Bill Currie 2022-01-04 17:53:10 +09:00
parent 9d74fcc181
commit f2b258ba76

View file

@ -1819,6 +1819,9 @@ pr_jump_mode (progs_t *pr, const dstatement_t *st)
jump_offs = OPA(uint) + OPB(int); jump_offs = OPA(uint) + OPB(int);
break; break;
} }
if (pr_boundscheck->int_val && jump_offs >= pr->progs->numstatements) {
PR_RunError (pr, "out of bounds: %x", jump_offs);
}
return jump_offs - 1; // for st++ return jump_offs - 1; // for st++
} }