From 8f712688b96284fb0e277df05b7ea8487789fe56 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Mon, 22 Nov 2021 20:32:46 -0800 Subject: [PATCH] Fix crash on call as last instruction in function --- vm/state.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vm/state.go b/vm/state.go index ba1ed6b..cfbbd91 100644 --- a/vm/state.go +++ b/vm/state.go @@ -79,11 +79,11 @@ func (state *State) processInstruction() { state.running = false } - if state.functionIndex < 0 || state.functionIndex >= int64(len(state.program.Functions)) { - state.ret() - } + for state.functionIndex < 0 || + state.functionIndex >= int64(len(state.program.Functions)) || + state.instructionIndex < 0 || + state.instructionIndex >= int64(len(state.function().Instructions)) { - if state.instructionIndex < 0 || state.instructionIndex >= int64(len(fnc.Instructions)) { state.ret() } }