Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
cb297af8
Commit
cb297af8
authored
Apr 09, 2014
by
Hisham Muhammad
Browse files
Fix invalid access when highlighting basename of threads.
parent
f2e4556b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Process.c
View file @
cb297af8
...
...
@@ -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
;
...
...
ProcessList.c
View file @
cb297af8
...
...
@@ -708,10 +708,10 @@ static bool ProcessList_readCmdlineFile(Process* process, const char* dirname, c
if
(
tokenEnd
==
0
)
{
tokenEnd
=
amtRead
;
}
process
->
basenameOffset
=
tokenEnd
;
command
[
amtRead
]
=
'\0'
;
free
(
process
->
comm
);
process
->
comm
=
strdup
(
command
);
process
->
basenameOffset
=
tokenEnd
;
return
true
;
}
...
...
@@ -831,10 +831,12 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P
if
(
process
->
state
==
'Z'
)
{
free
(
process
->
comm
);
process
->
basenameOffset
=
-
1
;
process
->
comm
=
strdup
(
command
);
}
else
if
(
Process_isThread
(
process
))
{
if
(
this
->
showThreadNames
||
Process_isKernelThread
(
process
)
||
process
->
state
==
'Z'
)
{
free
(
process
->
comm
);
process
->
basenameOffset
=
-
1
;
process
->
comm
=
strdup
(
command
);
}
else
if
(
this
->
showingThreadNames
)
{
if
(
!
ProcessList_readCmdlineFile
(
process
,
dirname
,
name
))
...
...
@@ -858,6 +860,7 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P
errorReadingProcess:
{
if
(
process
->
comm
)
{
free
(
process
->
comm
);
process
->
basenameOffset
=
-
1
;
process
->
comm
=
NULL
;
}
if
(
existingProcess
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment