mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-14 20:22:30 +00: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:
parent
4c3722aea8
commit
e6130a3090
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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user