nlr: If DEBUG, guard against recursive nlr_push().
Pushing same NLR record twice would lead to "infinite loop" in nlr_jump (but more realistically, it will crash as soon as NLR record on stack is overwritten).
This commit is contained in:
parent
53e5e0fa28
commit
e89cc13e5c
5
py/nlr.h
5
py/nlr.h
@ -88,6 +88,7 @@ void nlr_jump_fail(void *val);
|
||||
#ifndef DEBUG
|
||||
#define nlr_raise(val) nlr_jump(val)
|
||||
#else
|
||||
#include "mpstate.h"
|
||||
#define nlr_raise(val) \
|
||||
do { \
|
||||
void *_val = val; \
|
||||
@ -95,6 +96,10 @@ void nlr_jump_fail(void *val);
|
||||
assert(mp_obj_is_exception_instance(_val)); \
|
||||
nlr_jump(_val); \
|
||||
} while (0)
|
||||
|
||||
#define nlr_push(val) \
|
||||
assert(MP_STATE_VM(nlr_top) != val),nlr_push(val)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __MICROPY_INCLUDED_PY_NLR_H__
|
||||
|
Loading…
x
Reference in New Issue
Block a user