mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 20:40:05 +00:00
stdlib: Avoid another self-comparison in qsort
In the insertion phase, we could run off the start of the array if the comparison function never runs zero. In that case, it never finds the initial element that terminates the iteration. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
dd858522bf
commit
e4d8117b82
@ -217,7 +217,7 @@ insertion_sort_qsort_partitions (void *const pbase, size_t total_elems,
|
||||
while ((run_ptr += size) <= end_ptr)
|
||||
{
|
||||
tmp_ptr = run_ptr - size;
|
||||
while (cmp (run_ptr, tmp_ptr, arg) < 0)
|
||||
while (run_ptr != tmp_ptr && cmp (run_ptr, tmp_ptr, arg) < 0)
|
||||
tmp_ptr -= size;
|
||||
|
||||
tmp_ptr += size;
|
||||
|
Loading…
Reference in New Issue
Block a user