Util: Fix nullptr derefencing

In order to compare strings, the STL has to dereference the data
pointer. So check if its not a nullptr first.
This commit is contained in:
Riyyi
2021-09-13 03:59:51 +02:00
parent 7759821b13
commit a5d5d2ea6d
+1 -1
View File
@@ -141,7 +141,7 @@ bool ArgParser::parseLongOption(std::string_view option, std::string_view next)
printf("Parsing long option: '%s' with value '%s'\n", name.data(), argumentProvided ? value.data() : ""); printf("Parsing long option: '%s' with value '%s'\n", name.data(), argumentProvided ? value.data() : "");
auto foundOption = std::find_if(m_options.begin(), m_options.end(), [&name](Option& it) -> bool { auto foundOption = std::find_if(m_options.begin(), m_options.end(), [&name](Option& it) -> bool {
return it.longName == name; return it.longName && it.longName == name;
}); });
if (foundOption == m_options.cend()) { if (foundOption == m_options.cend()) {