From 6b0314f14b3e7fe7e4a36ce1ca1fe5f466ad3fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 26 Jan 2024 10:19:21 +0800 Subject: [PATCH] Platform: fix exe path detection --- src/util/platform/FFPlatform_unix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/platform/FFPlatform_unix.c b/src/util/platform/FFPlatform_unix.c index 7500261a4..a233c3bc4 100644 --- a/src/util/platform/FFPlatform_unix.c +++ b/src/util/platform/FFPlatform_unix.c @@ -29,11 +29,13 @@ static void getExePath(FFPlatform* platform) (int[]){CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, (int) getpid()}, 4, exePath->chars, &exePathLen, NULL, 0 - )) + ) < 0) exePathLen = 0; + else + exePathLen--; // remove terminating NUL #endif if (exePathLen > 0) - exePath->length = (uint32_t) (exePathLen - 1); + exePath->length = (uint32_t) exePathLen; } static void platformPathAddEnv(FFlist* dirs, const char* env)