forked from TrueCloudLab/neoneo-go
vm: fail if XTUCK argument is 0
This commit is contained in:
parent
b21a220712
commit
d257044298
2 changed files with 10 additions and 1 deletions
|
@ -375,7 +375,7 @@ func (v *VM) execute(ctx *Context, op Instruction) {
|
|||
|
||||
case XTUCK:
|
||||
n := int(v.estack.Pop().BigInt().Int64())
|
||||
if n < 0 {
|
||||
if n <= 0 {
|
||||
panic("XTUCK: invalid length")
|
||||
}
|
||||
a := v.estack.Dup(0)
|
||||
|
|
|
@ -658,6 +658,15 @@ func TestXTUCKbadNegative(t *testing.T) {
|
|||
assert.Equal(t, true, vm.state.HasFlag(faultState))
|
||||
}
|
||||
|
||||
func TestXTUCKbadZero(t *testing.T) {
|
||||
prog := makeProgram(XTUCK)
|
||||
vm := load(prog)
|
||||
vm.estack.PushVal(1)
|
||||
vm.estack.PushVal(0)
|
||||
vm.Run()
|
||||
assert.Equal(t, true, vm.state.HasFlag(faultState))
|
||||
}
|
||||
|
||||
func TestXTUCKgood(t *testing.T) {
|
||||
prog := makeProgram(XTUCK)
|
||||
topelement := 5
|
||||
|
|
Loading…
Reference in a new issue