From b0ef284962dd2d58c81493cb55150d7fdb820690 Mon Sep 17 00:00:00 2001 From: Stanislav Denisov Date: Tue, 13 Jan 2026 11:17:52 +0100 Subject: [PATCH] Fix config getters crash caused by empty strings (#1489) --- WickedEngine/wiConfig.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/WickedEngine/wiConfig.cpp b/WickedEngine/wiConfig.cpp index cca982030..ed3993a0c 100644 --- a/WickedEngine/wiConfig.cpp +++ b/WickedEngine/wiConfig.cpp @@ -13,7 +13,7 @@ namespace wi::config bool Section::GetBool(const char* name) const { - auto it = values.find(name); + const auto it = values.find(name); if (it == values.end()) { return 0; @@ -26,11 +26,15 @@ namespace wi::config { return false; } + if (it->second.empty()) + { + return 0; + } return std::stoi(it->second) != 0; } int Section::GetInt(const char* name) const { - auto it = values.find(name); + const auto it = values.find(name); if (it == values.end()) { return 0; @@ -43,11 +47,15 @@ namespace wi::config { return 0; } + if (it->second.empty()) + { + return 0; + } return std::stoi(it->second); } uint32_t Section::GetUint(const char* name) const { - auto it = values.find(name); + const auto it = values.find(name); if (it == values.end()) { return 0u; @@ -60,11 +68,15 @@ namespace wi::config { return 0u; } + if (it->second.empty()) + { + return 0u; + } return (uint32_t)std::stoul(it->second); } float Section::GetFloat(const char* name) const { - auto it = values.find(name); + const auto it = values.find(name); if (it == values.end()) { return 0; @@ -77,11 +89,15 @@ namespace wi::config { return 0; } + if (it->second.empty()) + { + return 0; + } return std::stof(it->second); } std::string Section::GetText(const char* name) const { - auto it = values.find(name); + const auto it = values.find(name); if (it == values.end()) { return "";