From 1005c1f7dbb0f2d96c48e3d9e314d072f72bde5d Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 6 Jun 2022 11:52:26 +0300 Subject: [PATCH] vm: forbid jumping out of the script bounds --- pkg/vm/context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/vm/context.go b/pkg/vm/context.go index c468e115e..5cdbf9a4c 100644 --- a/pkg/vm/context.go +++ b/pkg/vm/context.go @@ -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