Skip to content

Commit 8970ede

Browse files
committed
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 <[email protected]>
1 parent 23bfa95 commit 8970ede

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

extmod/moductypes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ static mp_obj_t uctypes_struct_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
602602
uint agg_type = GET_TYPE(offset, AGG_TYPE_BITS);
603603
if (agg_type == PTR) {
604604
byte *p = *(void **)self->addr;
605-
return mp_obj_new_int((mp_int_t)(uintptr_t)p);
605+
return mp_obj_new_int_from_uint((uintptr_t)p);
606606
}
607607
}
608608
MP_FALLTHROUGH
@@ -629,7 +629,7 @@ static mp_int_t uctypes_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo,
629629
static mp_obj_t uctypes_struct_addressof(mp_obj_t buf) {
630630
mp_buffer_info_t bufinfo;
631631
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ);
632-
return mp_obj_new_int((mp_int_t)(uintptr_t)bufinfo.buf);
632+
return mp_obj_new_int_from_uint((uintptr_t)bufinfo.buf);
633633
}
634634
MP_DEFINE_CONST_FUN_OBJ_1(uctypes_struct_addressof_obj, uctypes_struct_addressof);
635635

0 commit comments

Comments
 (0)