vm: forbid jumping out of the script bounds

This commit is contained in:
Anna Shaleva 2022-06-06 11:52:26 +03:00
parent a5b5f88fe2
commit 1005c1f7db

View file

@ -91,7 +91,7 @@ func (c *Context) NextIP() int {
// Jump unconditionally moves the next instruction pointer to the specified location.
func (c *Context) Jump(pos int) {
if pos < 0 || pos > len(c.prog) {
if pos < 0 || pos >= len(c.prog) {
panic("instruction offset is out of range")
}
c.nextip = pos