From 2cfc8ec0db68420ae039ff1625698b6fb02ab21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 13 Nov 2024 10:46:30 +0800 Subject: [PATCH] Processing (macOS): fix exe path detection --- src/common/processing_linux.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index c170cd56c..3b290bc3d 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -147,7 +147,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons if (length > 0) // doesn't contain trailing NUL { buf[length] = '\0'; - ffStrbufEnsureFixedLengthFree(exePath, (uint32_t)length + 1); // +1 for the NUL + ffStrbufEnsureFixedLengthFree(exePath, (uint32_t)length); ffStrbufAppendNS(exePath, (uint32_t)length, buf); } } @@ -193,11 +193,12 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons } else { - ffStrbufEnsureFixedLengthFree(exe, PATH_MAX); - int length = proc_pidpath(pid, exe->chars, exe->allocated); + char buf[PROC_PIDPATHINFO_MAXSIZE]; + int length = proc_pidpath(pid, buf, ARRAY_SIZE(buf)); if (length > 0) { - exe->length = (uint32_t) length; + ffStrbufEnsureFixedLengthFree(exe, (uint32_t) length); + ffStrbufAppendNS(exe, (uint32_t) length, buf); if (exePath) ffStrbufSet(exePath, exe); } @@ -273,7 +274,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons if (length > 0) // doesn't contain trailing NUL { buf[length] = '\0'; - ffStrbufEnsureFixedLengthFree(exePath, (uint32_t)length + 1); // +1 for the NUL + ffStrbufEnsureFixedLengthFree(exePath, (uint32_t)length); ffStrbufAppendNS(exePath, (uint32_t)length, buf); } }