all repos — mgba @ c3b411fb6b99e91f6f8582f699345806099facf2

mGBA Game Boy Advance Emulator

Util: Fix wrap condition on RingFIFORead if it's empty
Jeffrey Pfau jeffrey@endrift.com
Thu, 18 Aug 2016 00:04:07 -0700
commit

c3b411fb6b99e91f6f8582f699345806099facf2

parent

041113b09cb8ac12b132cd2be03d3489966376d3

1 files changed, 4 insertions(+), 0 deletions(-)

jump to
M src/util/ring-fifo.csrc/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; }