Browse Source

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.
master
Riyyi 3 years ago
parent
commit
a5d5d2ea6d
  1. 2
      src/util/argparser.cpp

2
src/util/argparser.cpp

@ -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()) {

Loading…
Cancel
Save