[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
This commit is contained in:
Yaya-Cout
2023-09-28 20:38:40 +02:00
parent fd159fe489
commit a0583aa2a9

View File

@@ -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. */