From 42dfca47cfb8c212e5f099f8c2aae076801e2d33 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Sat, 31 Aug 2019 09:06:56 +0300 Subject: [PATCH] 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. --- pkg/vm/cli/cli.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/vm/cli/cli.go b/pkg/vm/cli/cli.go index b3d4efb36..84bc8ebcd 100644 --- a/pkg/vm/cli/cli.go +++ b/pkg/vm/cli/cli.go @@ -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":