diff options
| author | Damien George <damien.p.george@gmail.com> | 2014-08-13 13:22:24 +0100 | 
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2014-08-13 13:22:24 +0100 | 
| commit | 9b7a8ee8f1032a1c9172afe0bd3ac5be7780e4a2 (patch) | |
| tree | 79b3b74827761d1db8b2081a2e1e2be24322a527 /py/objlist.c | |
| parent | 9d02780eafd9546354fd3ac429b0211f52331650 (diff) | |
py: Fix mult by negative number of tuple, list, str, bytes.
Multiplication of a tuple, list, str or bytes now yields an empty
sequence (instead of crashing).  Addresses issue #799
Also added ability to mult bytes on LHS by integer.
Diffstat (limited to 'py/objlist.c')
| -rw-r--r-- | py/objlist.c | 3 | 
1 files changed, 3 insertions, 0 deletions
| diff --git a/py/objlist.c b/py/objlist.c index 655a78908..578e39452 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -131,6 +131,9 @@ STATIC mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {              if (!mp_obj_get_int_maybe(rhs, &n)) {                  return MP_OBJ_NULL; // op not supported              } +            if (n < 0) { +                n = 0; +            }              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; | 
