vm: fix double VM run from CLI

Fixes one more instruction being ran when VM FAULTs:

NEO-GO-VM > run
NEO-GO-VM > error encountered at instruction 6 (ROLL)
NEO-GO-VM > runtime error: invalid memory address or nil pointer dereference
FAULT
NEO-GO-VM > error encountered at instruction 7 (SETITEM)
NEO-GO-VM > interface conversion: interface {} is []vm.StackItem, not []uint8

Refs. #96.
This commit is contained in:
Roman Khimov 2019-08-31 09:06:56 +03:00
parent 428e789ddc
commit 42dfca47cf

View file

@ -127,16 +127,13 @@ func (c *VMCLI) handleCommand(cmd string, args ...string) {
fmt.Printf("READY: loaded %d instructions\n", c.vm.Context().LenInstr())
case "run":
var (
method []byte
params []vm.StackItem
err error
start int
)
if len(args) == 0 {
c.vm.Run()
} else {
if len(args) != 0 {
var (
method []byte
params []vm.StackItem
err error
start int
)
if isMethodArg(args[0]) {
method = []byte(args[0])
start = 1
@ -146,8 +143,8 @@ func (c *VMCLI) handleCommand(cmd string, args ...string) {
fmt.Println(err)
return
}
c.vm.LoadArgs(method, params)
}
c.vm.LoadArgs(method, params)
c.vm.Run()
case "cont":