summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/Options.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2016-06-29 20:23:03 +0000
committerEnrico Granata <egranata@apple.com>2016-06-29 20:23:03 +0000
commitdadf7b293d732ebe984c4a16cdddf4cb31364fff (patch)
treec8d5c9e8d3b3c1a921484b4d3411029e1adaeee0 /lldb/source/Interpreter/Options.cpp
parent3f5275e8edd53383a943c2f6ab8e80409528af78 (diff)
downloadbcm5719-llvm-dadf7b293d732ebe984c4a16cdddf4cb31364fff.tar.gz
bcm5719-llvm-dadf7b293d732ebe984c4a16cdddf4cb31364fff.zip
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
Diffstat (limited to 'lldb/source/Interpreter/Options.cpp')
-rw-r--r--lldb/source/Interpreter/Options.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index c1a32e316eb..70f532ed75d 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -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;
OpenPOWER on IntegriCloud