aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Munns <[email protected]>2024-01-29 16:22:02 +0000
committerGitHub <[email protected]>2024-01-29 16:22:02 +0000
commit3cd0a54e0e3e7dd4b480034106b8b24144d2385b (patch)
tree5f33febbaffecddb9d7bf1815b562ffff496a3cb
parent681393150dcb9704e55bcb315cb7793e0f56607e (diff)
parent0708ce1410404ebf66c94fadc71cb7b0128161d3 (diff)
Merge pull request #2492 from JomerDev/fix-read_to_break
Fix underflow in embassy-rp uartrx.read_to_break
-rw-r--r--embassy-rp/src/uart/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs
index 9f5ba4e8a..f372cb640 100644
--- a/embassy-rp/src/uart/mod.rs
+++ b/embassy-rp/src/uart/mod.rs
@@ -604,8 +604,8 @@ impl<'d, T: Instance> UartRx<'d, T, Async> {
604 return match (all_full, last_was_break) { 604 return match (all_full, last_was_break) {
605 (true, true) | (false, _) => { 605 (true, true) | (false, _) => {
606 // We got less than the full amount + a break, or the full amount 606 // We got less than the full amount + a break, or the full amount
607 // and the last byte was a break. Subtract the break off. 607 // and the last byte was a break. Subtract the break off by adding one to sval.
608 Ok((next_addr - 1) - sval) 608 Ok(next_addr.saturating_sub(1 + sval))
609 } 609 }
610 (true, false) => { 610 (true, false) => {
611 // We finished the whole DMA, and the last DMA'd byte was NOT a break 611 // We finished the whole DMA, and the last DMA'd byte was NOT a break