vm: do not allow APPEND to operate on bytearray

This commit is contained in:
Evgenii Stratonikov 2019-09-11 17:08:36 +03:00
parent 723dcc6e25
commit 68c6c93980
2 changed files with 9 additions and 3 deletions

View file

@ -641,9 +641,6 @@ func (v *VM) execute(ctx *Context, op Instruction) {
arr := t.Value().([]StackItem)
arr = append(arr, itemElem.value)
t.value = arr
case *ByteArrayItem:
newVal := append(t.value, itemElem.value.Value().([]byte)...)
v.estack.PushVal(newVal)
default:
panic("APPEND: not of underlying type Array")
}

View file

@ -479,6 +479,15 @@ func TestAPPENDBad1Argument(t *testing.T) {
assert.Equal(t, true, vm.state.HasFlag(faultState))
}
func TestAPPENDWrongType(t *testing.T) {
prog := makeProgram(APPEND)
vm := load(prog)
vm.estack.PushVal([]byte{})
vm.estack.PushVal(1)
vm.Run()
assert.Equal(t, true, vm.state.HasFlag(faultState))
}
func TestSIGNNoArgument(t *testing.T) {
prog := makeProgram(SIGN)
vm := load(prog)