From 4a7e60ef5778c2e2d586820310d48e25fa4e30fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 7 Mar 2024 21:31:11 +0800 Subject: [PATCH] CPU (Linux): don't crash if `/sys/devices/system/cpu/cpufreq/` doesn't exist Ref: #750 --- src/detection/cpu/cpu_linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index d21401f9f..00936133a 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -107,6 +107,8 @@ static bool detectFrequency(FFCPUResult* cpu) { FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/devices/system/cpu/cpufreq/"); FF_AUTO_CLOSE_DIR DIR* dir = opendir(path.chars); + if (!dir) return false; + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); uint32_t baseLen = path.length; bool flag = false;