From ce626319c273383a8f8d1a7d9f549f4d487699ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 14 Oct 2013 19:15:24 -0400 Subject: [PATCH] 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 --- src/shared/cgroup-show.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c index cc44ab4..aa0f017 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; -- 1.8.4.652.g0d6e0ce