summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/objlist.c6
1 files 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;
}