Validate the option index before trying to access an array element using it - OptionArgElement can potentially use negative indices to mean interesting, but non option, states

llvm-svn: 274159
This commit is contained in:
Enrico Granata 2016-06-29 20:23:03 +00:00
parent 3f5275e8ed
commit dadf7b293d
1 changed files with 7 additions and 0 deletions

View File

@ -964,6 +964,13 @@ Options::HandleOptionArgumentCompletion
for (size_t i = 0; i < opt_element_vector.size(); i++)
{
int cur_defs_index = opt_element_vector[i].opt_defs_index;
// trying to use <0 indices will definitely cause problems
if (cur_defs_index == OptionArgElement::eUnrecognizedArg ||
cur_defs_index == OptionArgElement::eBareDash ||
cur_defs_index == OptionArgElement::eBareDoubleDash)
continue;
int cur_arg_pos = opt_element_vector[i].opt_arg_pos;
const char *cur_opt_name = opt_defs[cur_defs_index].long_option;