diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-28 02:25:04 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-28 02:25:04 +0300 |
commit | 8993fb6cf0677ce980ab56cbad326e4e6bc47811 (patch) | |
tree | c40ec3264ff4e6ff2574bf3f8c465ab406cfa631 /py/obj.c | |
parent | 7e4ec3bf4f90232d3193425519ed0fc1b708c27f (diff) | |
download | micropython-8993fb6cf0677ce980ab56cbad326e4e6bc47811.tar.gz micropython-8993fb6cf0677ce980ab56cbad326e4e6bc47811.zip |
py: Add protection against printing too nested or recursive data structures.
With a test which cannot be automatically validated so far.
Diffstat (limited to 'py/obj.c')
-rw-r--r-- | py/obj.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -35,6 +35,7 @@ #include "obj.h" #include "runtime0.h" #include "runtime.h" +#include "stackctrl.h" mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { if (MP_OBJ_IS_SMALL_INT(o_in)) { @@ -59,6 +60,8 @@ void printf_wrapper(void *env, const char *fmt, ...) { } void mp_obj_print_helper(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) { + // There can be data structures nested too deep, or just recursive + STACK_CHECK(); #if !NDEBUG if (o_in == NULL) { print(env, "(nil)"); |