mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01: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
1 changed files with 1 additions and 1 deletions
|
@ -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…
Add table
Reference in a new issue