From 20e3d6a19bb6222164baa54b65abad85c75e534e Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 23 Jun 2026 07:57:55 +0200 Subject: [PATCH] dev.7, fix crash --- CHANGELOG_LATEST.md | 2 ++ src/core/shuntingYard.cpp | 9 ++++++++- src/emsesp_version.h | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index dec97659a..1d968a2b6 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -12,6 +12,8 @@ For more details go to [emsesp.org](https://emsesp.org/). - signed value for solarInfuence [#3077](https://github.com/emsesp/EMS-ESP32/issues/3077) - set bin file upload limit to 1M again [3086](https://github.com/emsesp/EMS-ESP32/issues/3086) +- check arithmetric operations on strings [#3127](https://github.com/emsesp/EMS-ESP32/discussions/3127) +- Prevent system crash during WiFi network discovery on ESP32-S3 hardware [#3128](https://github.com/emsesp/EMS-ESP32/pull/3128) ## Changed diff --git a/src/core/shuntingYard.cpp b/src/core/shuntingYard.cpp index 0e8da02c2..fd51bbf5e 100644 --- a/src/core/shuntingYard.cpp +++ b/src/core/shuntingYard.cpp @@ -333,7 +333,10 @@ std::deque shuntingYard(const std::deque & tokens) { // check if string is a number bool isnum(const std::string & s) { - if (!s.empty() && (s.find_first_not_of("0123456789.") == std::string::npos || (s[0] == '-' && s.find_first_not_of("0123456789.", 1) == std::string::npos))) { + if (s.empty() || s.find_first_of("0123456789") == std::string::npos) { + return false; + } + if (s.find_first_not_of("0123456789.") == std::string::npos || (s[0] == '-' && s.find_first_not_of("0123456789.", 1) == std::string::npos)) { return true; } return false; @@ -636,6 +639,10 @@ std::string calculate(const std::string & expr) { stack.push_back(lhs + rhs); break; } + if (!isnum(rhs) || !isnum(lhs)) { + stack.push_back(lhs + token.str + rhs); + break; + } auto lhd = std::stod(lhs); auto rhd = std::stod(rhs); switch (token.str[0]) { diff --git a/src/emsesp_version.h b/src/emsesp_version.h index 340c555c0..74e1e397b 100644 --- a/src/emsesp_version.h +++ b/src/emsesp_version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.8.3-dev.6" +#define EMSESP_APP_VERSION "3.8.3-dev.7"