From 8e0cd6f4c60da314c2a61f6a7b7e10179c15f6a0 Mon Sep 17 00:00:00 2001 From: mmmorks Date: Tue, 8 Sep 2026 00:10:52 -0700 Subject: [PATCH] CLI: stop the bare `gps` command crashing when no GPS was detected The status branch does strcmp(_sensors->getSettingByKey("gps"), "1"). getSettingByKey() returns NULL when no "gps" setting is registered, which is the case whenever gps_detected was false at boot, and strcmp() then dereferences it. Treat a missing setting as "deactivated". --- src/helpers/CommonCLI.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index 4930e81e9a..e73af5b77a 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -396,7 +396,11 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re bool enabled = l->isEnabled(); // is EN pin on ? bool fix = l->isValid(); // has fix ? int sats = l->satellitesCount(); - bool active = !strcmp(_sensors->getSettingByKey("gps"), "1"); + // getSettingByKey() returns NULL when no "gps" setting is registered + // (no GPS detected at boot) -- treat that as "deactivated" rather than + // handing strcmp() a NULL, which crashes. + const char* gps_setting = _sensors->getSettingByKey("gps"); + bool active = gps_setting != NULL && strcmp(gps_setting, "1") == 0; if (enabled) { sprintf(reply, "on, %s, %s, %d sats", active?"active":"deactivated",