From e5a15cb7a5a548e6e38cd82661af181fda038206 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 4 Feb 2014 09:44:10 +0200 Subject: [PATCH] mp_obj_new_list(n, items): Copy items only if not-NULL. Similar to mp_obj_new_tuple(). --- py/objlist.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/py/objlist.c b/py/objlist.c index 59a4ad6b12..aa857e41c2 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -435,8 +435,10 @@ static mp_obj_list_t *list_new(uint n) { mp_obj_t mp_obj_new_list(uint n, mp_obj_t *items) { mp_obj_list_t *o = list_new(n); - for (int i = 0; i < n; i++) { - o->items[i] = items[i]; + if (items != NULL) { + for (int i = 0; i < n; i++) { + o->items[i] = items[i]; + } } return o; }