summaryrefslogtreecommitdiff
path: root/py/objlist.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-02-04 15:33:36 -0800
committerScott Shawcroft <scott@tannewt.org>2019-02-04 15:33:36 -0800
commitc60f77d5ab5c68f1fdaf0c734b77629418c7f903 (patch)
treea508cac0f7747a19d6dfe74aec119943f9edaae6 /py/objlist.c
parent9bcc38e995648493fe35ad63a18bd65d63f64c21 (diff)
Check sequence multiply for length overflow
Fixes #1279
Diffstat (limited to 'py/objlist.c')
-rw-r--r--py/objlist.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/py/objlist.c b/py/objlist.c
index 67940e44c..16ca4b353 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -126,7 +126,8 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
if (n < 0) {
n = 0;
}
- mp_obj_list_t *s = list_new(o->len * n);
+ size_t new_len = mp_seq_multiply_len(o->len, n);
+ mp_obj_list_t *s = list_new(new_len);
mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items);
return MP_OBJ_FROM_PTR(s);
}