Commit 08242eed authored by Damien George's avatar Damien George
Browse files

py/nlrsetjmp: Add check for failed NLR jump.

Also optimise the function so it only needs to call the MP_STATE_THREAD
macro once (following how other nlr code is written).
parent fe79234c
...@@ -29,10 +29,14 @@ ...@@ -29,10 +29,14 @@
#if MICROPY_NLR_SETJMP #if MICROPY_NLR_SETJMP
void nlr_setjmp_jump(void *val) { void nlr_setjmp_jump(void *val) {
nlr_buf_t *buf = MP_STATE_THREAD(nlr_top); nlr_buf_t **top_ptr = &MP_STATE_THREAD(nlr_top);
MP_STATE_THREAD(nlr_top) = buf->prev; nlr_buf_t *top = *top_ptr;
buf->ret_val = val; if (top == NULL) {
longjmp(buf->jmpbuf, 1); nlr_jump_fail(val);
}
top->ret_val = val;
*top_ptr = top->prev;
longjmp(top->jmpbuf, 1);
} }
#endif #endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment