mirror of
https://github.com/intel/llvm.git
synced 2026-01-21 04:14:03 +08:00
Fix a crash in option parsing.
The call to getopt_long didn't handle the case where the *last* option had an argument missing. <rdar://problem/51231882> Differential Revision: https://reviews.llvm.org/D63110 llvm-svn: 363101
This commit is contained in:
1
lldb/lit/Driver/Inputs/process_attach_pid.in
Normal file
1
lldb/lit/Driver/Inputs/process_attach_pid.in
Normal file
@@ -0,0 +1 @@
|
||||
process attach --pid
|
||||
2
lldb/lit/Driver/TestProcessAttach.test
Normal file
2
lldb/lit/Driver/TestProcessAttach.test
Normal file
@@ -0,0 +1,2 @@
|
||||
# RUN: %lldb -x -b -S %S/Inputs/process_attach_pid.in 2>&1 | FileCheck %s
|
||||
# CHECK: requires an argument
|
||||
@@ -1362,6 +1362,12 @@ llvm::Expected<Args> Options::Parse(const Args &args,
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user