diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-02-15 20:23:52 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-02-15 20:23:52 +0300 |
commit | e89cc13e5c4fa05d7f14dabedf3ac21a2dd57084 (patch) | |
tree | 7997f906b1af294b2e724dd37062c2915eea0515 /py/nlr.h | |
parent | 53e5e0fa28d0f81be8671303ea0388da71fd20b6 (diff) |
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).
Diffstat (limited to 'py/nlr.h')
-rw-r--r-- | py/nlr.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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__ |