Vouch request: fix CircBuf resize state corruption #13516
What do you want to change?I’d like to fix a state-consistency bug in src/datastruct/circ_buf.zig when CircBuf.resize shrinks a partially filled buffer. After reallocating the storage, resize currently updates head and full only when the buffer grows. When a partially filled buffer is shrunk below its current length, the old metadata can remain in place, leaving head beyond the new capacity and causing len() to report more elements than the buffer can contain. A later append can then access the storage out of bounds. Why do you want to make this change?This change would preserve the core invariants of CircBuf after resizing: the length should never exceed capacity, indices should always remain within the allocated storage, and a buffer retaining exactly its new capacity should be marked as full. I acknowledge that:
|
Answered by
jcollie
Jul 30, 2026
Replies: 1 comment
|
!vouch |
0 replies
Answer selected by
jcollie
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!vouch