Skip to content

Commit e5a15cb

Browse files
committed
mp_obj_new_list(n, items): Copy items only if not-NULL.
Similar to mp_obj_new_tuple().
1 parent 0c59db1 commit e5a15cb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

py/objlist.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,10 @@ static mp_obj_list_t *list_new(uint n) {
435435

436436
mp_obj_t mp_obj_new_list(uint n, mp_obj_t *items) {
437437
mp_obj_list_t *o = list_new(n);
438-
for (int i = 0; i < n; i++) {
439-
o->items[i] = items[i];
438+
if (items != NULL) {
439+
for (int i = 0; i < n; i++) {
440+
o->items[i] = items[i];
441+
}
440442
}
441443
return o;
442444
}

0 commit comments

Comments
 (0)