This revision was automatically updated to reflect the committed changes.
Closed by commit rL363101: Fix a crash in option parsing. (authored by adrian, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63110?vs=203940&id=204164#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63110/new/

https://reviews.llvm.org/D63110

Files:
  lldb/trunk/lit/Driver/Inputs/process_attach_pid.in
  lldb/trunk/lit/Driver/TestProcessAttach.test
  lldb/trunk/source/Interpreter/Options.cpp


Index: lldb/trunk/source/Interpreter/Options.cpp
===================================================================
--- lldb/trunk/source/Interpreter/Options.cpp
+++ lldb/trunk/source/Interpreter/Options.cpp
@@ -1362,6 +1362,12 @@
     int long_options_index = -1;
     val = OptionParser::Parse(argv.size(), &*argv.begin(), sstr.GetString(),
                               long_options, &long_options_index);
+
+    if ((size_t)OptionParser::GetOptionIndex() > argv.size()) {
+      error.SetErrorStringWithFormat("option requires an argument");
+      break;
+    }
+
     if (val == -1)
       break;
 
Index: lldb/trunk/lit/Driver/Inputs/process_attach_pid.in
===================================================================
--- lldb/trunk/lit/Driver/Inputs/process_attach_pid.in
+++ lldb/trunk/lit/Driver/Inputs/process_attach_pid.in
@@ -0,0 +1 @@
+process attach --pid
Index: lldb/trunk/lit/Driver/TestProcessAttach.test
===================================================================
--- lldb/trunk/lit/Driver/TestProcessAttach.test
+++ lldb/trunk/lit/Driver/TestProcessAttach.test
@@ -0,0 +1,2 @@
+# RUN: %lldb -x -b -S %S/Inputs/process_attach_pid.in 2>&1 | FileCheck %s
+# CHECK: requires an argument


Index: lldb/trunk/source/Interpreter/Options.cpp
===================================================================
--- lldb/trunk/source/Interpreter/Options.cpp
+++ lldb/trunk/source/Interpreter/Options.cpp
@@ -1362,6 +1362,12 @@
     int long_options_index = -1;
     val = OptionParser::Parse(argv.size(), &*argv.begin(), sstr.GetString(),
                               long_options, &long_options_index);
+
+    if ((size_t)OptionParser::GetOptionIndex() > argv.size()) {
+      error.SetErrorStringWithFormat("option requires an argument");
+      break;
+    }
+
     if (val == -1)
       break;
 
Index: lldb/trunk/lit/Driver/Inputs/process_attach_pid.in
===================================================================
--- lldb/trunk/lit/Driver/Inputs/process_attach_pid.in
+++ lldb/trunk/lit/Driver/Inputs/process_attach_pid.in
@@ -0,0 +1 @@
+process attach --pid
Index: lldb/trunk/lit/Driver/TestProcessAttach.test
===================================================================
--- lldb/trunk/lit/Driver/TestProcessAttach.test
+++ lldb/trunk/lit/Driver/TestProcessAttach.test
@@ -0,0 +1,2 @@
+# RUN: %lldb -x -b -S %S/Inputs/process_attach_pid.in 2>&1 | FileCheck %s
+# CHECK: requires an argument
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to