From: Zbigniew Jędrzejewski-Szmek Date: Mon, 14 Oct 2013 23:15:24 +0000 (-0400) Subject: Fix bad assert in show_pid_array X-Git-Tag: v209~1881 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=a0551d26ab5c6e0d5089b42a6319baef0e28ad92 Fix bad assert in show_pid_array This function should get the same treatment as other qsort uses did in 7ff7394 "Never call qsort on potentially NULL arrays". Reported-by: Oleksii Shevchuk --- diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c index 979fa8fdd..ce02b76e3 100644 --- a/src/shared/cgroup-show.c +++ b/src/shared/cgroup-show.c @@ -44,8 +44,6 @@ static void show_pid_array(int pids[], unsigned n_pids, const char *prefix, unsi unsigned i, m, pid_width; pid_t biggest = 0; - assert(n_pids > 0); - /* Filter duplicates */ m = 0; for (i = 0; i < n_pids; i++) { @@ -65,7 +63,7 @@ static void show_pid_array(int pids[], unsigned n_pids, const char *prefix, unsi pid_width = DECIMAL_STR_WIDTH(biggest); /* And sort */ - qsort(pids, n_pids, sizeof(pid_t), compare); + qsort_safe(pids, n_pids, sizeof(pid_t), compare); if (flags & OUTPUT_FULL_WIDTH) n_columns = 0;