forked from TrueCloudLab/neoneo-go
vm: make LEFT fail if count is too big
This commit is contained in:
parent
22791272bf
commit
9dca2288ba
2 changed files with 2 additions and 2 deletions
|
@ -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]))
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue