From 7e54296c6d346803efb51da9850783547c33f1df Mon Sep 17 00:00:00 2001 From: Matt Page Date: Thu, 18 Jan 2024 16:51:16 -0800 Subject: [PATCH] Assert valid occupancy when adding to ringbuf --- Modules/_queuemodule.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/_queuemodule.c b/Modules/_queuemodule.c index a6e9c43cbfac53..5f4a141a9ac93b 100644 --- a/Modules/_queuemodule.c +++ b/Modules/_queuemodule.c @@ -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) {