Util: Fix wrap condition on RingFIFORead if it's empty

This commit is contained in:
Jeffrey Pfau 2016-08-18 00:04:07 -07:00
parent 041113b09c
commit c3b411fb6b
1 changed files with 4 additions and 0 deletions

View File

@ -75,6 +75,10 @@ size_t RingFIFORead(struct RingFIFO* buffer, void* output, size_t length) {
// 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;
}