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() } }