[Lldb-commits] [lldb] r274159 - 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

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 29 13:23:04 PDT 2016


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;
 




More information about the lldb-commits mailing list