Skip to content

Commit eaa7745

Browse files
committed
py/objint: Fix left-shift overflow in checking for large int.
1 parent b32a38e commit eaa7745

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/objint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
383383

384384
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
385385
// If result guaranteedly fits in small int, use that
386-
if (!MP_SMALL_INT_FITS(1 << (bufinfo.len * 8 - 1))) {
386+
if (bufinfo.len >= sizeof(mp_uint_t) || !MP_SMALL_INT_FITS(1 << (bufinfo.len * 8 - 1))) {
387387
return mp_obj_int_from_bytes_impl(args[2] != MP_OBJ_NEW_QSTR(MP_QSTR_little), bufinfo.len, bufinfo.buf);
388388
} else
389389
#endif

0 commit comments

Comments
 (0)