diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index ba14f3700..1b3d93004 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -694,7 +694,7 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro } s := v.estack.Pop().Bytes() if t := len(s); l > t { - l = t + panic("size is too big") } v.estack.PushVal(NewBufferItem(s[:l])) diff --git a/pkg/vm/vm_test.go b/pkg/vm/vm_test.go index cb14a0fa7..d7a1666ef 100644 --- a/pkg/vm/vm_test.go +++ b/pkg/vm/vm_test.go @@ -1814,7 +1814,7 @@ func TestLEFT(t *testing.T) { t.Run("NoString", getTestFuncForVM(prog, nil, 2)) t.Run("NegativeLen", getTestFuncForVM(prog, nil, "abcdef", -1)) t.Run("Good", getTestFuncForVM(prog, NewBufferItem([]byte("ab")), "abcdef", 2)) - t.Run("GoodBigLen", getTestFuncForVM(prog, NewBufferItem([]byte("abcdef")), "abcdef", 8)) + t.Run("BadBigLen", getTestFuncForVM(prog, nil, "abcdef", 8)) } func TestRIGHT(t *testing.T) {