Skip to content

Commit

Permalink
Check for snek_abort right after instruction execution
Browse files Browse the repository at this point in the history
This avoids doing any instruction final steps on partially computed
data, and also avoids needing two checks for abort.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Feb 9, 2019
1 parent 583672e commit de88f11
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions snek-code.c
Expand Up @@ -982,8 +982,8 @@ snek_code_run(snek_code_t *code_in)
snek_offset_t ip = 0;
snek_offset_t o;

while (snek_code && !snek_abort) {
while (!snek_abort && ip < snek_code->size) {
while (snek_code) {
while (ip < snek_code->size) {
#ifdef DEBUG_EXEC
snek_code_dump_instruction(snek_code, ip);
#endif
Expand Down Expand Up @@ -1146,6 +1146,8 @@ snek_code_run(snek_code_t *code_in)
default:
break;
}
if (snek_abort)
goto abort;
if (push)
snek_stack_push(snek_a);
#ifdef DEBUG_EXEC
Expand All @@ -1165,6 +1167,7 @@ snek_code_run(snek_code_t *code_in)
snek_stack_push(snek_a);
}
}
abort:
/* Clear references to run objects */
snek_code = NULL;
snek_frame = NULL;
Expand Down

0 comments on commit de88f11

Please sign in to comment.