mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-10 05:03:06 +03: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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user