Avoid invalid string access in ObjCLanguage::MethodName::SetName

Summary:
Don't access `name[1]  if the string is only of length 1.  Avoids a
crash/assertion failure when parsing the string `-`.

Test Plan:
Debug a swift binary, set a breakpoint, watch lldb not crash

Original change by Paul Menage <menage@fb.com>

Reviewers: lldb-commits, clayborg

Differential Revision: https://reviews.llvm.org/D33853

llvm-svn: 304725
This commit is contained in:
Stephane Sezer 2017-06-05 17:44:04 +00:00
parent d454c73cc3
commit ca5e153fb1
1 changed files with 1 additions and 1 deletions

View File

@ -95,7 +95,7 @@ bool ObjCLanguage::MethodName::SetName(llvm::StringRef name, bool strict) {
// or '-' can be omitted
bool valid_prefix = false;
if (name[0] == '+' || name[0] == '-') {
if (name.size() > 1 && (name[0] == '+' || name[0] == '-')) {
valid_prefix = name[1] == '[';
if (name[0] == '+')
m_type = eTypeClassMethod;