diff --git a/Process.c b/Process.c index 7ca234498..9db13a647 100644 --- a/Process.c +++ b/Process.c @@ -64,7 +64,7 @@ void Process_fillStarttimeBuffer(Process* this) { */ #define TASK_COMM_LEN 16 -static bool findCommInCmdline(const char* comm, const char* cmdline, size_t cmdlineBasenameStart, size_t* pCommStart, size_t* pCommEnd) { +static bool findCommInCmdline(const char* comm, const char* cmdline, size_t cmdlineBasenameStart, size_t* pCommStart, size_t* pCommLen) { /* Try to find procComm in tokenized cmdline - this might in rare cases * mis-identify a string or fail, if comm or cmdline had been unsuitably * modified by the process */ @@ -83,7 +83,7 @@ static bool findCommInCmdline(const char* comm, const char* cmdline, size_t cmdl if ((tokenLen == commLen || (tokenLen > commLen && commLen == (TASK_COMM_LEN - 1))) && strncmp(tokenBase, comm, commLen) == 0) { *pCommStart = (size_t)(tokenBase - cmdline); - *pCommEnd = (size_t)(token - cmdline); + *pCommLen = tokenLen; return true; } @@ -381,13 +381,9 @@ void Process_makeCommandStr(Process* this, const Settings* settings) { bool haveCommInCmdline = false; size_t commStart = 0; - size_t commEnd = 0; if (!haveCommInExe && this->cmdline && procComm && searchCommInCmdline && (!Process_isUserlandThread(this) || showThreadNames)) { - haveCommInCmdline = findCommInCmdline(procComm, cmdline, cmdlineBasenameStart, &commStart, &commEnd); - } - if (haveCommInCmdline) { - commLen = commEnd - commStart; + haveCommInCmdline = findCommInCmdline(procComm, cmdline, cmdlineBasenameStart, &commStart, &commLen); } if (!stripExeFromCmdline) {