Util: Fix wrap condition on RingFIFORead if it's empty
Jeffrey Pfau jeffrey@endrift.com
Thu, 18 Aug 2016 00:04:07 -0700
1 files changed,
4 insertions(+),
0 deletions(-)
jump to
M
src/util/ring-fifo.c
→
src/util/ring-fifo.c
@@ -75,6 +75,10 @@ ATOMIC_LOAD(end, buffer->writePtr);
// Wrap around if we can't fit enough in here if ((intptr_t) data - (intptr_t) buffer->data + length >= buffer->capacity) { + if (end == data) { + // Oops! If we wrap now, it'll appear full + return 0; + } data = buffer->data; }