summaryrefslogtreecommitdiff
path: root/src/systemctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemctl.c')
-rw-r--r--src/systemctl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/systemctl.c b/src/systemctl.c
index fb3430048c..8cdc01aa49 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -502,8 +502,10 @@ static int list_units(DBusConnection *bus, char **args, unsigned n) {
c++;
}
- qsort(unit_infos, c, sizeof(struct unit_info), compare_unit_info);
- output_units_list(unit_infos, c);
+ if (c > 0) {
+ qsort(unit_infos, c, sizeof(struct unit_info), compare_unit_info);
+ output_units_list(unit_infos, c);
+ }
r = 0;