From 8270e3853dc167d2d7946bb0de7a0f0bb2adde48 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 3 Apr 2014 11:00:54 +0000 Subject: py: More robust int conversion and overflow checking. --- py/objlist.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'py/objlist.c') diff --git a/py/objlist.c b/py/objlist.c index 244d4a596..2a5f2c883 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -122,12 +122,11 @@ STATIC mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { list_extend(lhs, rhs); return o; } - case MP_BINARY_OP_MULTIPLY: - { - if (!MP_OBJ_IS_SMALL_INT(rhs)) { + case MP_BINARY_OP_MULTIPLY: { + machine_int_t n; + if (!mp_obj_get_int_maybe(rhs, &n)) { return NULL; } - int n = MP_OBJ_SMALL_INT_VALUE(rhs); mp_obj_list_t *s = list_new(o->len * n); mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items); return s; -- cgit v1.2.3