diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-10 16:59:56 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-10 16:59:56 +0000 |
commit | 190d1ba297621b7a266fdde8968d163fd5018f2f (patch) | |
tree | da3a503f58a61b539f8ad236a383038096aa2a9e /py | |
parent | a1ef441d18facf29ae135a48e924aa7f68e9825c (diff) | |
download | micropython-190d1ba297621b7a266fdde8968d163fd5018f2f.tar.gz micropython-190d1ba297621b7a266fdde8968d163fd5018f2f.zip |
py: Make sure state/stack of byte code function has at least 1 slot.
Diffstat (limited to 'py')
-rw-r--r-- | py/emitbc.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/py/emitbc.c b/py/emitbc.c index 4857428cb8..74f324176e 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -232,6 +232,12 @@ STATIC void emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { { byte* c = emit_get_cur_to_write_byte_code(emit, 4); uint n_state = scope->num_locals + scope->stack_size; + if (n_state == 0) { + // Need at least 1 entry in the state, in the case an exception is + // propagated through this function, the exception is returned in + // the highest slot in the state (fastn[0], see vm.c). + n_state = 1; + } c[0] = n_state & 0xff; c[1] = (n_state >> 8) & 0xff; c[2] = scope->exc_stack_size & 0xff; |