Skip to content

Commit aaa091f

Browse files
committed
Terminal (Linux): fix segfault
1 parent 53cd1e5 commit aaa091f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/detection/terminalshell/terminalshell_linux.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
312312

313313
static bool getTerminalInfoByPidEnv(FFTerminalResult* result, const char* pidEnv)
314314
{
315-
pid_t pid = (pid_t) strtol(getenv(pidEnv), NULL, 10);
315+
const char* envStr = getenv(pidEnv);
316+
if (envStr == NULL)
317+
return false;
318+
319+
pid_t pid = (pid_t) strtol(envStr, NULL, 10);
316320
result->pid = (uint32_t) pid;
317321
char name[256];
318322
if (getProcessNameAndPpid(pid, name, (pid_t*) &result->ppid, NULL) == NULL)

0 commit comments

Comments
 (0)