1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core/ringbuffer: compensate 'ringbuffer_remove' underflow error

When rb->start = rb->size, `ringbuffer_get_one(ringbuffer_t *restrict rb)`
will read out of bounds.
This commit is contained in:
mjc 2020-01-06 14:41:12 +08:00 committed by Francisco Molina
parent 0d4d621f99
commit 7f44c02f45

View File

@ -121,7 +121,7 @@ unsigned ringbuffer_remove(ringbuffer_t *restrict rb, unsigned n)
rb->avail -= n;
/* compensate underflow */
if (rb->start > rb->size) {
if (rb->start >= rb->size) {
rb->start -= rb->size;
}
}