dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
923a60
From 33088d83ecaf03611e3d20a893e675e4d7c3ae9a Mon Sep 17 00:00:00 2001
923a60
From: Umut Tezduyar Lindskog <umut.tezduyar@axis.com>
923a60
Date: Wed, 11 Mar 2015 11:24:18 +0100
923a60
Subject: [PATCH] cgtop: fix assert when not on tty
923a60
923a60
systemd-cgtop --dept=1 -b -n 10 -d 0.1 | cat
923a60
923a60
Assertion 'new_length >= 3' failed at src/shared/util.c:3 \
923a60
595, function ellipsize_mem(). Aborting.
923a60
Aborted (core dumped)
923a60
923a60
(David: add comment)
923a60
923a60
(cherry picked from commit 510c4a0f1e7e7efe2897d2fbb9067f121467b103)
923a60
---
923a60
 src/cgtop/cgtop.c | 2 +-
923a60
 1 file changed, 1 insertion(+), 1 deletion(-)
923a60
923a60
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
923a60
index 3c7ad40605..f951c37cbc 100644
923a60
--- a/src/cgtop/cgtop.c
923a60
+++ b/src/cgtop/cgtop.c
923a60
@@ -447,7 +447,7 @@ static int display(Hashmap *a) {
923a60
         Group *g;
923a60
         Group **array;
923a60
         signed path_columns;
923a60
-        unsigned rows, n = 0, j, maxtcpu = 0, maxtpath = 0;
923a60
+        unsigned rows, n = 0, j, maxtcpu = 0, maxtpath = 3; /* 3 for ellipsize() to work properly */
923a60
         char buffer[MAX3(21, FORMAT_BYTES_MAX, FORMAT_TIMESPAN_MAX)];
923a60
 
923a60
         assert(a);