diff options
| author | Damien George | 2014-04-03 11:00:54 +0000 |
|---|---|---|
| committer | Damien George | 2014-04-03 11:00:54 +0000 |
| commit | 8270e3853dc167d2d7946bb0de7a0f0bb2adde48 (patch) | |
| tree | e261ee333b53fbe4560c94e37a531eaae2c0d60e /py/objlist.c | |
| parent | a58a7aefbd330261cc5c79c9fc9d5c6a12d2aeeb (diff) | |
py: More robust int conversion and overflow checking.
Diffstat (limited to 'py/objlist.c')
| -rw-r--r-- | py/objlist.c | 7 |
1 files changed, 3 insertions, 4 deletions
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; |
