From d90d7ed00280d997f6022420a5185a395d719b4d Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Sun, 14 Jul 2024 16:00:55 +0200 Subject: Fix off-by-one in queue `back` and `back_ptr` procs --- core/container/queue/queue.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/container/queue/queue.odin') diff --git a/core/container/queue/queue.odin b/core/container/queue/queue.odin index e7a60dde0..f83a5f2b7 100644 --- a/core/container/queue/queue.odin +++ b/core/container/queue/queue.odin @@ -95,11 +95,11 @@ front_ptr :: proc(q: ^$Q/Queue($T)) -> ^T { } back :: proc(q: ^$Q/Queue($T)) -> T { - idx := (q.offset+uint(q.len))%builtin.len(q.data) + idx := (q.offset+uint(q.len - 1))%builtin.len(q.data) return q.data[idx] } back_ptr :: proc(q: ^$Q/Queue($T)) -> ^T { - idx := (q.offset+uint(q.len))%builtin.len(q.data) + idx := (q.offset+uint(q.len - 1))%builtin.len(q.data) return &q.data[idx] } -- cgit v1.2.3