chiark / gitweb /
Fix bad assert in show_pid_array
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 14 Oct 2013 23:15:24 +0000 (19:15 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 14 Oct 2013 23:16:25 +0000 (19:16 -0400)
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 <alxchk@gmail.com>
src/shared/cgroup-show.c

index 979fa8fddf6e776fa1db2b70e261e36f866f6582..ce02b76e368a266b1b7ad4c96b7c7524be5cfd18 100644 (file)
@@ -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;