If the index specified is equal to the size of the data, return NULL.
@@ -311,7 +311,7 @@ static inline void *circlebuf_data(struct circlebuf *cb, size_t idx)
uint8_t *ptr = (uint8_t*)cb->data;
size_t offset = cb->start_pos + idx;
- if (idx > cb->size)
+ if (idx >= cb->size)
return NULL;
if (offset >= cb->capacity)