Fix out of bounds bug in ovnisort

This commit is contained in:
Rodrigo Arias 2021-12-13 19:16:34 +01:00
parent 363562e028
commit 1eb90de88b

2
sort.c
View File

@ -98,7 +98,7 @@ find_destination(struct ring *r, uint64_t clock)
start = r->tail - 1 >= 0 ? r->tail - 1 : r->size - 1; start = r->tail - 1 >= 0 ? r->tail - 1 : r->size - 1;
end = r->head - 1 >= 0 ? r->head - 1 : r->size - 1; end = r->head - 1 >= 0 ? r->head - 1 : r->size - 1;
for(i=start; i != end; i = i-1 < 0 ? r->size : i-1) for(i=start; i != end; i = i-1 < 0 ? r->size - 1: i-1)
{ {
if(r->ev[i]->header.clock < clock) if(r->ev[i]->header.clock < clock)
{ {