summaryrefslogtreecommitdiffstats
path: root/Process.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2014-04-09 17:43:54 -0300
committerHisham Muhammad <hisham@gobolinux.org>2014-04-09 17:43:54 -0300
commitcb297af8487daae6a6f552d17b13d29912882584 (patch)
tree14c3c826a0789e891ed6376a84dee6b4f1e9025a /Process.c
parentf2e4556b5ec51a714cb94bf5ceee729e3c542b6d (diff)
Fix invalid access when highlighting basename of threads.
Diffstat (limited to 'Process.c')
-rw-r--r--Process.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Process.c b/Process.c
index 04804810..97f2fff2 100644
--- a/Process.c
+++ b/Process.c
@@ -405,14 +405,13 @@ static inline void Process_writeCommand(Process* this, int attr, int baseattr, R
RichString_append(str, attr, this->comm);
if (this->pl->highlightBaseName) {
int finish = RichString_size(str) - 1;
- int space = start + this->basenameOffset;
- if (space != -1)
- finish = space - 1;
+ if (this->basenameOffset != -1)
+ finish = (start + this->basenameOffset) - 1;
int colon = RichString_findChar(str, ':', start);
if (colon != -1 && colon < finish) {
finish = colon;
} else {
- for (int i = finish - start; i > 0; i--) {
+ for (int i = finish - start; i >= 0; i--) {
if (this->comm[i] == '/') {
start += i+1;
break;
@@ -648,6 +647,7 @@ Process* Process_new(struct ProcessList_ *pl) {
this->utime = 0;
this->stime = 0;
this->comm = NULL;
+ this->basenameOffset = -1;
this->indent = 0;
#ifdef HAVE_CGROUP
this->cgroup = NULL;

© 2014-2024 Faster IT GmbH | imprint | privacy policy