mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-04 19:19:44 +00:00
vm: limit types accepted for PICKITEM, fix #965
bafdb916a0
change was wrong (probably brought
from neo-vm 3.0 at the state at which it existed back then), neo-vm 2.x
doesn't allow PICKITEM for arbitrary types.
This commit is contained in:
parent
328c6d7ce5
commit
1721360dd1
2 changed files with 2 additions and 9 deletions
|
@ -1029,12 +1029,7 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
|||
}
|
||||
v.estack.Push(&Element{value: t.value[index].Value.Dup()})
|
||||
default:
|
||||
arr := obj.Bytes()
|
||||
if index < 0 || index >= len(arr) {
|
||||
panic("PICKITEM: invalid index")
|
||||
}
|
||||
item := arr[index]
|
||||
v.estack.PushVal(int(item))
|
||||
panic("PICKITEM: unknown type")
|
||||
}
|
||||
|
||||
case opcode.SETITEM:
|
||||
|
|
|
@ -1367,9 +1367,7 @@ func TestPICKITEMByteArray(t *testing.T) {
|
|||
vm := load(prog)
|
||||
vm.estack.PushVal([]byte{1, 2})
|
||||
vm.estack.PushVal(1)
|
||||
runVM(t, vm)
|
||||
assert.Equal(t, 1, vm.estack.Len())
|
||||
assert.Equal(t, makeStackItem(2), vm.estack.Pop().value)
|
||||
checkVMFailed(t, vm)
|
||||
}
|
||||
|
||||
func TestPICKITEMDupArray(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue