forked from TrueCloudLab/neoneo-go
vm: do not allow APPEND to operate on bytearray
This commit is contained in:
parent
723dcc6e25
commit
68c6c93980
2 changed files with 9 additions and 3 deletions
|
@ -641,9 +641,6 @@ func (v *VM) execute(ctx *Context, op Instruction) {
|
||||||
arr := t.Value().([]StackItem)
|
arr := t.Value().([]StackItem)
|
||||||
arr = append(arr, itemElem.value)
|
arr = append(arr, itemElem.value)
|
||||||
t.value = arr
|
t.value = arr
|
||||||
case *ByteArrayItem:
|
|
||||||
newVal := append(t.value, itemElem.value.Value().([]byte)...)
|
|
||||||
v.estack.PushVal(newVal)
|
|
||||||
default:
|
default:
|
||||||
panic("APPEND: not of underlying type Array")
|
panic("APPEND: not of underlying type Array")
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,6 +479,15 @@ func TestAPPENDBad1Argument(t *testing.T) {
|
||||||
assert.Equal(t, true, vm.state.HasFlag(faultState))
|
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) {
|
func TestSIGNNoArgument(t *testing.T) {
|
||||||
prog := makeProgram(SIGN)
|
prog := makeProgram(SIGN)
|
||||||
vm := load(prog)
|
vm := load(prog)
|
||||||
|
|
Loading…
Reference in a new issue