summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/objfun.c5
-rw-r--r--py/vm.c10
2 files changed, 10 insertions, 5 deletions
diff --git a/py/objfun.c b/py/objfun.c
index 187bb5a59e..70b897b57d 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -161,7 +161,10 @@ mp_code_state *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, mp_uint_t n_arg
// allocate state for locals and stack
mp_uint_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t);
mp_code_state *code_state;
- code_state = m_new_obj_var(mp_code_state, byte, state_size);
+ code_state = m_new_obj_var_maybe(mp_code_state, byte, state_size);
+ if (!code_state) {
+ return NULL;
+ }
code_state->n_state = n_state;
code_state->ip = ip;
diff --git a/py/vm.c b/py/vm.c
index 3a7a816977..2359f1f019 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -874,10 +874,12 @@ unwind_jump:;
code_state->sp = sp;
code_state->exc_sp = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block);
mp_code_state *new_state = mp_obj_fun_bc_prepare_codestate(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1);
- new_state->prev = code_state;
- code_state = new_state;
- nlr_pop();
- goto run_code_state;
+ if (new_state) {
+ new_state->prev = code_state;
+ code_state = new_state;
+ nlr_pop();
+ goto run_code_state;
+ }
}
#endif
SET_TOP(mp_call_function_n_kw(*sp, unum & 0xff, (unum >> 8) & 0xff, sp + 1));