From 0bc15941c2d9f9b0e05fdf0e96f1a7b843912be6 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 10 May 2014 21:05:45 +0300 Subject: [PATCH] py: Make mp_obj_print() handle null object w/o segfault if debug build. Happens regularly when used for debugging. --- py/obj.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/py/obj.c b/py/obj.c index 8c6c3e7349..6494a847a5 100644 --- a/py/obj.c +++ b/py/obj.c @@ -59,6 +59,12 @@ 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) { +#if !NDEBUG + if (o_in == NULL) { + print(env, "(nil)"); + return; + } +#endif mp_obj_type_t *type = mp_obj_get_type(o_in); if (type->print != NULL) { type->print(print, env, o_in, kind);