ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
9fc0f6
From 50f0e2315d0c22d2e98e53ff02e7ae2412463e9a Mon Sep 17 00:00:00 2001
9fc0f6
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
9fc0f6
Date: Mon, 14 Oct 2013 19:15:24 -0400
9fc0f6
Subject: [PATCH] Fix bad assert in show_pid_array
9fc0f6
9fc0f6
This function should get the same treatment as other qsort uses
9fc0f6
did in 7ff7394 "Never call qsort on potentially NULL arrays".
9fc0f6
9fc0f6
Reported-by: Oleksii Shevchuk <alxchk@gmail.com>
9fc0f6
---
9fc0f6
 src/shared/cgroup-show.c | 4 +---
9fc0f6
 1 file changed, 1 insertion(+), 3 deletions(-)
9fc0f6
9fc0f6
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
9fc0f6
index cc44ab4..aa0f017 100644
9fc0f6
--- a/src/shared/cgroup-show.c
9fc0f6
+++ b/src/shared/cgroup-show.c
9fc0f6
@@ -44,8 +44,6 @@ static void show_pid_array(int pids[], unsigned n_pids, const char *prefix, unsi
9fc0f6
         unsigned i, m, pid_width;
9fc0f6
         pid_t biggest = 0;
9fc0f6
 
9fc0f6
-        assert(n_pids > 0);
9fc0f6
-
9fc0f6
         /* Filter duplicates */
9fc0f6
         m = 0;
9fc0f6
         for (i = 0; i < n_pids; i++) {
9fc0f6
@@ -65,7 +63,7 @@ static void show_pid_array(int pids[], unsigned n_pids, const char *prefix, unsi
9fc0f6
         pid_width = DECIMAL_STR_WIDTH(biggest);
9fc0f6
 
9fc0f6
         /* And sort */
9fc0f6
-        qsort(pids, n_pids, sizeof(pid_t), compare);
9fc0f6
+        qsort_safe(pids, n_pids, sizeof(pid_t), compare);
9fc0f6
 
9fc0f6
         if(flags & OUTPUT_FULL_WIDTH)
9fc0f6
                 n_columns = 0;