diff options
author | Damien George <damien.p.george@gmail.com> | 2017-01-25 14:39:13 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-01-25 14:39:13 +1100 |
commit | eaa77455c37cf18670d181556e6d17e0b01c2267 (patch) | |
tree | 3d00e5b5a3fc5adf2a3ca2b452f4915af01b44d2 /py/objint.c | |
parent | b32a38e373dc1e30ea26cc58f7e6e791e50190f4 (diff) |
py/objint: Fix left-shift overflow in checking for large int.
Diffstat (limited to 'py/objint.c')
-rw-r--r-- | py/objint.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objint.c b/py/objint.c index a61ed8e27..222aa1de7 100644 --- a/py/objint.c +++ b/py/objint.c @@ -383,7 +383,7 @@ STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) { #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE // If result guaranteedly fits in small int, use that - if (!MP_SMALL_INT_FITS(1 << (bufinfo.len * 8 - 1))) { + if (bufinfo.len >= sizeof(mp_uint_t) || !MP_SMALL_INT_FITS(1 << (bufinfo.len * 8 - 1))) { return mp_obj_int_from_bytes_impl(args[2] != MP_OBJ_NEW_QSTR(MP_QSTR_little), bufinfo.len, bufinfo.buf); } else #endif |