Skip to content

Commit

Permalink
Assert valid occupancy when adding to ringbuf
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Jan 19, 2024
1 parent ead8814 commit 7e54296
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Modules/_queuemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ RingBuf_Get(RingBuf *buf)
static int
RingBuf_Put(RingBuf *buf, PyObject *item)
{
assert(buf->num_items <= buf->items_cap);

if (buf->num_items == buf->items_cap) {
// Buffer is full, grow it.
if (resize_ringbuf(buf, buf->items_cap * 2) < 0) {
Expand Down

0 comments on commit 7e54296

Please sign in to comment.