From 76b8446d15e54af6511e1b3f4a02886095ae036f Mon Sep 17 00:00:00 2001 From: Carter Li Date: Mon, 17 Jun 2024 15:18:02 +0800 Subject: [PATCH] InitSystem (SunOS): fix crashes --- src/common/processing_linux.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index c4db9216d..af3f4ebf5 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -247,13 +247,16 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons ffStrbufSubstrBeforeFirstC(exe, ' '); } - snprintf(filePath, sizeof(filePath), "/proc/%d/path/a.out", (int) pid); - ffStrbufEnsureFixedLengthFree(exePath, PATH_MAX); - ssize_t length = readlink(filePath, exePath->chars, exePath->allocated - 1); - if (length > 0) // doesn't contain trailing NUL + if (exePath) { - exePath->chars[length] = '\0'; - exePath->length = (uint32_t) length; + snprintf(filePath, sizeof(filePath), "/proc/%d/path/a.out", (int) pid); + ffStrbufEnsureFixedLengthFree(exePath, PATH_MAX); + ssize_t length = readlink(filePath, exePath->chars, exePath->allocated - 1); + if (length > 0) // doesn't contain trailing NUL + { + exePath->chars[length] = '\0'; + exePath->length = (uint32_t) length; + } } #endif