diff options
| author | Dan Halbert <halbert@halwitz.org> | 2018-12-07 15:34:43 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-07 15:34:43 -0500 |
| commit | 2fbaceb2b15ff7d2c368a6cf4dfc10881f5979e7 (patch) | |
| tree | 60210206b73c579e74288333a3ecc4e8f233dd1b /py | |
| parent | 481c4954afd161448aa37d353fa577d409d880c6 (diff) | |
| parent | 89ef6eef575501e736ae528f13d9979e1302be63 (diff) | |
Merge pull request #1294 from tannewt/stack_check4.0.0-alpha.4
Add stack validity check and raise an error when it happens.
Diffstat (limited to 'py')
| -rw-r--r-- | py/obj.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -33,10 +33,12 @@ #include "py/objtype.h" #include "py/objint.h" #include "py/objstr.h" +#include "py/qstr.h" #include "py/runtime.h" #include "py/stackctrl.h" #include "py/stream.h" // for mp_obj_print +#include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { @@ -81,7 +83,7 @@ void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) { // helper function to print an exception with traceback void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { - if (mp_obj_is_exception_instance(exc)) { + if (mp_obj_is_exception_instance(exc) && stack_ok()) { size_t n, *values; mp_obj_exception_get_traceback(exc, &n, &values); if (n > 0) { @@ -486,6 +488,8 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(base); if (type->subscr != NULL) { mp_obj_t ret = type->subscr(base, index, value); + // May have called port specific C code. Make sure it didn't mess up the heap. + assert_heap_ok(); if (ret != MP_OBJ_NULL) { return ret; } |
