summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-11-24 15:06:30 +1100
committerDamien George <damien@micropython.org>2024-12-18 11:00:08 +1100
commit8970ede7cccee57032b547b8a97539b64e61102a (patch)
tree1101e59564d27158488059a1194f8385bf571243
parent23bfa95d34e9b6f836ee67a1564e04f7b86eaa36 (diff)
downloadmicropython-8970ede7cccee57032b547b8a97539b64e61102a.tar.gz
micropython-8970ede7cccee57032b547b8a97539b64e61102a.zip
extmod/moductypes: Fix large return values of addressof and INT_MAYBE.
So they don't return a negative number for an address (prior to this fix they would return negative addresses for values that were larger than the maximum small-int value). Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--extmod/moductypes.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/extmod/moductypes.c b/extmod/moductypes.c
index 00a69a275a..bf45797658 100644
--- a/extmod/moductypes.c
+++ b/extmod/moductypes.c
@@ -602,7 +602,7 @@ static mp_obj_t uctypes_struct_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
uint agg_type = GET_TYPE(offset, AGG_TYPE_BITS);
if (agg_type == PTR) {
byte *p = *(void **)self->addr;
- return mp_obj_new_int((mp_int_t)(uintptr_t)p);
+ return mp_obj_new_int_from_uint((uintptr_t)p);
}
}
MP_FALLTHROUGH
@@ -629,7 +629,7 @@ static mp_int_t uctypes_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo,
static mp_obj_t uctypes_struct_addressof(mp_obj_t buf) {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ);
- return mp_obj_new_int((mp_int_t)(uintptr_t)bufinfo.buf);
+ return mp_obj_new_int_from_uint((uintptr_t)bufinfo.buf);
}
MP_DEFINE_CONST_FUN_OBJ_1(uctypes_struct_addressof_obj, uctypes_struct_addressof);