From a0583aa2a9ea416f6b9cdfe8acbb30b170707a7a Mon Sep 17 00:00:00 2001 From: Yaya-Cout Date: Thu, 28 Sep 2023 20:38:40 +0200 Subject: [PATCH] [python] Prevent waiting for 2^32 ms if user entered a negative delay This is due to a missing check in the interruptible sleep function which was not checking if the delay was negative, then was passed to the Ion::Timing::usleep function, who only takes signed values --- python/port/helpers.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/port/helpers.cpp b/python/port/helpers.cpp index 1a425556fdc..35e33902604 100644 --- a/python/port/helpers.cpp +++ b/python/port/helpers.cpp @@ -33,6 +33,11 @@ void micropython_port_vm_hook_refresh_print() { } bool micropython_port_interruptible_msleep(int32_t delay) { + // Check if the user entered a bad delay (negative) + if (delay < 0) { + return false; + } + assert(delay >= 0); /* We don't use millis because the systick drifts when changing the HCLK * frequency. */