Fixed bug in vm_execute_all, if no OP_HALT then program kept going
This adds a bound on vm_execute_all to stop program->ptr from going past program->max.
This commit is contained in:
@@ -129,7 +129,8 @@ void vm_execute_all(vm_t *vm)
|
||||
size_t cycles = 0;
|
||||
size_t prev_sptr = 0;
|
||||
#endif
|
||||
while (program->instructions[program->ptr].opcode != OP_HALT)
|
||||
while (program->instructions[program->ptr].opcode != OP_HALT &&
|
||||
program->ptr < program->max)
|
||||
{
|
||||
#if VERBOSE >= 1
|
||||
fprintf(stdout, "[vm_execute_all]: Trace(Cycle %lu)\n", cycles);
|
||||
|
||||
Reference in New Issue
Block a user