numpy_ringbuffer icon indicating copy to clipboard operation
numpy_ringbuffer copied to clipboard

Negative indices in unfull buffers unsafely access memory

Open fpdotmonkey opened this issue 4 years ago • 0 comments

In a partly-full buffer, if you take a negative index, it will refer that index to the end of the full length of the buffer as apposed to the end of the full portion of the buffer.

from numpy_ringbuffer import RingBuffer
r = RingBuffer(10)
for i in range(5):
    r.append(i)
print(r[-1])
# 3.5097786643241087e+64

fpdotmonkey avatar Sep 04 '20 00:09 fpdotmonkey