diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-02-04 21:23:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-04 21:23:27 -0800 |
| commit | 041a84e8f962e3591d1aa565cd6cea5a73d6d882 (patch) | |
| tree | 1f62a987e90a7cad559af2c207cc6ada778fba98 /py/objstr.c | |
| parent | 9bcc38e995648493fe35ad63a18bd65d63f64c21 (diff) | |
| parent | 844c20106bee7639f5fa83535806932bae354a71 (diff) | |
Merge pull request #1520 from tannewt/check_seq_multiply_for_overflow
Check sequence multiply for length overflow
Diffstat (limited to 'py/objstr.c')
| -rw-r--r-- | py/objstr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/py/objstr.c b/py/objstr.c index 9b6cb0cf4..7236d9772 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -332,8 +332,9 @@ mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i return mp_const_empty_bytes; } } + size_t new_len = mp_seq_multiply_len(lhs_len, n); vstr_t vstr; - vstr_init_len(&vstr, lhs_len * n); + vstr_init_len(&vstr, new_len); mp_seq_multiply(lhs_data, sizeof(*lhs_data), lhs_len, n, vstr.buf); return mp_obj_new_str_from_vstr(lhs_type, &vstr); } |
