diff --git a/ringbuffer/ringbuffer.go b/ringbuffer/ringbuffer.go index b363395..68d8d8a 100644 --- a/ringbuffer/ringbuffer.go +++ b/ringbuffer/ringbuffer.go @@ -77,6 +77,10 @@ func (rb *RingBuffer) ContainsItem(item string) bool { rb.mu.Lock() defer rb.mu.Unlock() + if rb.head == -1 { + return false + } + for i := 0; i < rb.size; i++ { index := (rb.head + i) % rb.size if rb.buffer[index] == item { @@ -86,3 +90,4 @@ func (rb *RingBuffer) ContainsItem(item string) bool { return false } +