From b4dc16010df1e04e1e5c619ebbb62819b05e415b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 26 Feb 2018 15:20:19 +1100 Subject: [PATCH] Fix out of bound read in ParameterParser::get_switch The empty string case was not correctly handled. Fixes #1883 --- src/parameters_parser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parameters_parser.cc b/src/parameters_parser.cc index 30e2c346..56b1e1cf 100644 --- a/src/parameters_parser.cc +++ b/src/parameters_parser.cc @@ -59,7 +59,7 @@ Optional ParametersParser::get_switch(StringView name) const for (size_t i = 0; i < m_params.size(); ++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{}; if (param == "--")