From 80003fbc46ecbddc79288583533e82f3d05af3ea Mon Sep 17 00:00:00 2001 From: Neil Horne <15316949+elecpower@users.noreply.github.com> Date: Tue, 18 Aug 2026 18:04:12 +1000 Subject: [PATCH] fix(simu): gracefully handle non-existent radio profile SD path (#7661) --- companion/src/simulation/wasmsimulatorinterface.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/companion/src/simulation/wasmsimulatorinterface.cpp b/companion/src/simulation/wasmsimulatorinterface.cpp index 42b7bd478..1698a6627 100644 --- a/companion/src/simulation/wasmsimulatorinterface.cpp +++ b/companion/src/simulation/wasmsimulatorinterface.cpp @@ -19,6 +19,7 @@ #include #include #include +#include // WAMR native callback: called by WASM module to get analog values in // ADC range (0..4096, center=2048). The WASM ADC driver does a direct @@ -231,6 +232,15 @@ bool WasmSimulatorInterface::loadModule() // NOTE: wasm_runtime_set_wasi_args() only stores pointers; the actual WASI // init happens inside wasm_runtime_instantiate(), so all buffers must remain // alive until after instantiation completes. + + // DO NOT trust the sd path as it could be invalid + // sdPath MUST point to an existing directory or the simulator will crash + // an empty directory value is safe + if (!QDir(m_sdPath).exists()) { + qWarning() << "SD path" << m_sdPath << "does not exist and has been ignored"; + m_sdPath.clear(); + } + QByteArray sdPathUtf8 = m_sdPath.toUtf8(); QByteArray settingsPathUtf8 = m_settingsPath.toUtf8(); const char * dirList[2] = {};