Merge pull request #141 from BeigeBox/fix/empty-mqtt-command-crash

Fix crash on empty MQTT command message
This commit is contained in:
Jonathan Naylor 2026-04-05 16:23:27 +01:00 committed by GitHub
commit e5d050ee43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,6 +62,12 @@ REMOTE_COMMAND CRemoteControl::processCommand(const std::string& command)
start = command.find_first_not_of(' ', end);
}
if (m_args.empty()) {
if (m_mqtt != nullptr)
m_mqtt->publish("response", "KO");
return REMOTE_COMMAND::NONE;
}
if (m_args.at(0U) == "enable" && m_args.size() >= ENABLE_ARGS) {
if (m_args.at(1U) == "net1")
m_command = REMOTE_COMMAND::ENABLE_NETWORK1;
@ -122,7 +128,8 @@ REMOTE_COMMAND CRemoteControl::processCommand(const std::string& command)
#endif
}
m_mqtt->publish("response", replyStr);
if (m_mqtt != nullptr)
m_mqtt->publish("response", replyStr);
return m_command;
}