From 5b6eaf870a42e3234ff3235b722ea8f78e1ff7d7 Mon Sep 17 00:00:00 2001 From: Artem Lytkin Date: Sat, 5 Sep 2026 00:44:39 +0300 Subject: [PATCH] alarm: validate epoch_time type in TimeAlarm constructor mp_obj_int_get_checked() assumes its argument is already an int and reads it as one. Passing anything else, such as the struct_time from time.localtime(), dereferences garbage and hard faults the board. Use mp_arg_validate_type_int() so a non-int raises TypeError naming the argument, matching the other int arguments in shared-bindings. --- shared-bindings/alarm/time/TimeAlarm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index a3df6ddf7fd..1f1e214bd4b 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -73,7 +73,7 @@ static mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE mp_raise_ValueError(MP_ERROR_TEXT("epoch_time not supported on this board")); #else - mp_uint_t epoch_time_secs = mp_obj_int_get_checked(args[ARG_epoch_time].u_obj); + mp_uint_t epoch_time_secs = mp_arg_validate_type_int(args[ARG_epoch_time].u_obj, MP_QSTR_epoch_time); timeutils_struct_time_t tm; struct_time_to_tm(rtc_get_time_source_time(), &tm);