From e7c6afbc6a3ffb2ce28c2ecda2518e377f438697 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Fri, 9 Jun 2023 20:59:17 +0200 Subject: [PATCH] Fix potential crash when resolving variables during shutdown --- src/utils/variable-string.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/variable-string.cpp b/src/utils/variable-string.cpp index 6d7dc422..eef5fe92 100644 --- a/src/utils/variable-string.cpp +++ b/src/utils/variable-string.cpp @@ -6,7 +6,7 @@ namespace advss { void StringVariable::Resolve() const { - if (switcher->variables.empty()) { + if (switcher && switcher->variables.empty()) { _resolvedValue = _value; return; } @@ -65,6 +65,10 @@ const char *StringVariable::c_str() const std::string SubstitueVariables(std::string str) { + if (!switcher) { + return str; + } + for (const auto &v : switcher->variables) { const auto &variable = std::dynamic_pointer_cast(v); const std::string pattern = "${" + variable->Name() + "}";