Terminal (Linux): fix segfault

This commit is contained in:
李通洲
2024-01-30 15:22:26 +08:00
parent 53cd1e5378
commit aaa091f23b
@@ -312,7 +312,11 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
static bool getTerminalInfoByPidEnv(FFTerminalResult* result, const char* pidEnv)
{
pid_t pid = (pid_t) strtol(getenv(pidEnv), NULL, 10);
const char* envStr = getenv(pidEnv);
if (envStr == NULL)
return false;
pid_t pid = (pid_t) strtol(envStr, NULL, 10);
result->pid = (uint32_t) pid;
char name[256];
if (getProcessNameAndPpid(pid, name, (pid_t*) &result->ppid, NULL) == NULL)