From e8dc500f245cfd521df1ec2525c735869b32c57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 29 May 2024 16:24:18 +0800 Subject: [PATCH] Processing (Linux): return errors more actively fix assertion errors --- src/common/processing_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 2d9a82b90..912cbc7f4 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -245,7 +245,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/stat", (int)pid); char buf[PROC_FILE_BUFFSIZ]; ssize_t nRead = ffReadFileData(procFilePath, sizeof(buf) - 1, buf); - if(nRead < 0) + if(nRead <= 8) return "ffReadFileData(/proc/pid/stat, PROC_FILE_BUFFSIZ-1, buf) failed"; buf[nRead] = '\0'; @@ -268,7 +268,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i { snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/comm", (int)pid); ssize_t nRead = ffReadFileBuffer(procFilePath, name); - if(nRead < 0) + if(nRead <= 0) return "ffReadFileBuffer(/proc/pid/comm, name) failed"; ffStrbufTrimRightSpace(name); }