Skip to content

Commit

Permalink
Fix overflow in ring buffer reading.
Browse files Browse the repository at this point in the history
  • Loading branch information
surban committed Mar 6, 2023
1 parent 0ad6830 commit 93e93c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion defmt-ringbuf/src/ring_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<const SIZE: usize> RingBuf for RingBuffer<SIZE> {
self.overwritten.store(true, Ordering::SeqCst);

let mut new_read_pos = to + 1;
if new_read_pos == SIZE {
if new_read_pos >= SIZE {
new_read_pos = 0;
}
self.read_pos.store(new_read_pos, Ordering::SeqCst);
Expand Down

0 comments on commit 93e93c8

Please sign in to comment.