Author: enrico Date: Wed Jun 29 15:23:03 2016 New Revision: 274159 URL: http://llvm.org/viewvc/llvm-project?rev=274159&view=rev Log: 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
Modified: lldb/trunk/source/Interpreter/Options.cpp Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=274159&r1=274158&r2=274159&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Wed Jun 29 15:23:03 2016 @@ -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; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits