diff --git a/CHANGELOG.md b/CHANGELOG.md index 91d8f0a7..985cce23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,11 @@ and a potential segmentation fault from specially crafted config files - Fixed incorrect inclusion of definition for extra validators [#1238][] - Fixed fuzz generated failure from crafted files introduced in recent release [#1238][] +- Removed some usage of static const std::string in inline function that had + potential memory issues when CLI11 is used with shared libraries, this likely + isn't a bug but the fix did result in smaller code size so was kept. [#1244][] +[#1244]: https://github.com/CLIUtils/CLI11/pull/1244 [#1238]: https://github.com/CLIUtils/CLI11/pull/1238 [#1239]: https://github.com/CLIUtils/CLI11/pull/1239 diff --git a/include/CLI/StringTools.hpp b/include/CLI/StringTools.hpp index 77899fd9..d7f5ce1a 100644 --- a/include/CLI/StringTools.hpp +++ b/include/CLI/StringTools.hpp @@ -165,14 +165,12 @@ CLI11_INLINE bool valid_name_string(const std::string &str); /// Verify an app name inline bool valid_alias_name_string(const std::string &str) { - static const std::string badChars{'\n', '\0'}; - return (str.find_first_of(badChars) == std::string::npos); + return ((str.find_first_of('\n') == std::string::npos) && (str.find_first_of('\0') == std::string::npos)); } /// check if a string is a container segment separator (empty or "%%") inline bool is_separator(const std::string &str) { - static const std::string sep("%%"); - return (str.empty() || str == sep); + return (str.empty() || (str.size() == 2 && str[0] == '%' && str[1] == '%')); } /// Verify that str consists of letters only