From 93e93c828db5fec21a4497936d26de3e232f8029 Mon Sep 17 00:00:00 2001 From: Sebastian Urban Date: Mon, 6 Mar 2023 15:15:02 +0100 Subject: [PATCH] Fix overflow in ring buffer reading. --- defmt-ringbuf/src/ring_buffer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defmt-ringbuf/src/ring_buffer.rs b/defmt-ringbuf/src/ring_buffer.rs index ca4114d..5059c40 100644 --- a/defmt-ringbuf/src/ring_buffer.rs +++ b/defmt-ringbuf/src/ring_buffer.rs @@ -105,7 +105,7 @@ impl RingBuf for RingBuffer { 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);