Skip to content

Commit ab620f4

Browse files
jeplerdpgeorge
authored andcommitted
py/mpprint: Fix printing pointers with upper bit set.
On a build like nanbox, `mp_uint_t` is wider than `u/intptr_t`. Using a signed type for fetching pointer values resulted in erroneous results: like `<function f at 0xfffffffff7a60bc0>` instead of `<function f at 0xf7a60bc0>`. Signed-off-by: Jeff Epler <[email protected]>
1 parent 87b7a9d commit ab620f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/mpprint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
530530
char fmt_chr = *fmt;
531531
mp_uint_t val;
532532
if (fmt_chr == 'p' || fmt_chr == 'P') {
533-
val = va_arg(args, intptr_t);
533+
val = va_arg(args, uintptr_t);
534534
}
535535
#if SUPPORT_LL_FORMAT
536536
else if (long_long_arg) {

0 commit comments

Comments
 (0)