From 4f1627f68e3b931147f94fdbd26b62237f20f683 Mon Sep 17 00:00:00 2001 From: kreasteve Date: Thu, 16 Mar 2023 10:56:22 +0100 Subject: [PATCH 1/3] bugfix --- ports/raspberrypi/bindings/rp2pio/StateMachine.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index ada9f46020..bbf076ba68 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -341,7 +341,10 @@ STATIC mp_obj_t rp2pio_statemachine_run(mp_obj_t self_obj, mp_obj_t instruction_ mp_buffer_info_t bufinfo; mp_get_buffer_raise(instruction_obj, &bufinfo, MP_BUFFER_READ); - common_hal_rp2pio_statemachine_run(self, bufinfo.buf, bufinfo.len); + if (bufinfo.len % 2 != 0) { + mp_raise_ValueError(translate("Program size invalid")); + } + common_hal_rp2pio_statemachine_run(self, bufinfo.buf, (size_t)bufinfo.len / 2); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(rp2pio_statemachine_run_obj, rp2pio_statemachine_run); From d7fb21ec7607fbeeaff4391125cb00f87ffbe148 Mon Sep 17 00:00:00 2001 From: kreasteve Date: Thu, 16 Mar 2023 11:02:41 +0100 Subject: [PATCH 2/3] Revert "bugfix" This reverts commit 4f1627f68e3b931147f94fdbd26b62237f20f683. --- ports/raspberrypi/bindings/rp2pio/StateMachine.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index bbf076ba68..ada9f46020 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -341,10 +341,7 @@ STATIC mp_obj_t rp2pio_statemachine_run(mp_obj_t self_obj, mp_obj_t instruction_ mp_buffer_info_t bufinfo; mp_get_buffer_raise(instruction_obj, &bufinfo, MP_BUFFER_READ); - if (bufinfo.len % 2 != 0) { - mp_raise_ValueError(translate("Program size invalid")); - } - common_hal_rp2pio_statemachine_run(self, bufinfo.buf, (size_t)bufinfo.len / 2); + common_hal_rp2pio_statemachine_run(self, bufinfo.buf, bufinfo.len); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(rp2pio_statemachine_run_obj, rp2pio_statemachine_run); From 208c081c95e70ebbccfd9f9eb2f4b0e1bd9b0eef Mon Sep 17 00:00:00 2001 From: kreasteve Date: Thu, 16 Mar 2023 11:10:57 +0100 Subject: [PATCH 3/3] bugfix_#7706 --- ports/raspberrypi/bindings/rp2pio/StateMachine.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index ada9f46020..bbf076ba68 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -341,7 +341,10 @@ STATIC mp_obj_t rp2pio_statemachine_run(mp_obj_t self_obj, mp_obj_t instruction_ mp_buffer_info_t bufinfo; mp_get_buffer_raise(instruction_obj, &bufinfo, MP_BUFFER_READ); - common_hal_rp2pio_statemachine_run(self, bufinfo.buf, bufinfo.len); + if (bufinfo.len % 2 != 0) { + mp_raise_ValueError(translate("Program size invalid")); + } + common_hal_rp2pio_statemachine_run(self, bufinfo.buf, (size_t)bufinfo.len / 2); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(rp2pio_statemachine_run_obj, rp2pio_statemachine_run);