Skip to content

Commit

Permalink
[python] Prevent waiting for 2^32 ms if user entered a negative delay
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Yaya-Cout committed Sep 28, 2023
1 parent fd159fe commit a0583aa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/port/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit a0583aa

Please sign in to comment.