Fix out of bound read in ParameterParser::get_switch
The empty string case was not correctly handled. Fixes #1883
This commit is contained in:
parent
18f0902824
commit
b4dc16010d
|
@ -59,7 +59,7 @@ Optional<StringView> ParametersParser::get_switch(StringView name) const
|
||||||
for (size_t i = 0; i < m_params.size(); ++i)
|
for (size_t i = 0; i < m_params.size(); ++i)
|
||||||
{
|
{
|
||||||
const auto& param = m_params[i];
|
const auto& param = m_params[i];
|
||||||
if (param[0_byte] == '-' and param.substr(1_byte) == name)
|
if (param.substr(0_byte, 1_byte) == "-" and param.substr(1_byte) == name)
|
||||||
return it->value.takes_arg ? m_params[i+1] : StringView{};
|
return it->value.takes_arg ? m_params[i+1] : StringView{};
|
||||||
|
|
||||||
if (param == "--")
|
if (param == "--")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user