Fix crash on call as last instruction in function

This commit is contained in:
Ian Gulliver
2021-11-22 20:32:46 -08:00
parent 5ae34243b4
commit 8f712688b9

View File

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