Skip to content

Commit ca5e153

Browse files
committed
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 <[email protected]> Reviewers: lldb-commits, clayborg Differential Revision: https://reviews.llvm.org/D33853 llvm-svn: 304725
1 parent d454c73 commit ca5e153

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ bool ObjCLanguage::MethodName::SetName(llvm::StringRef name, bool strict) {
9595
// or '-' can be omitted
9696
bool valid_prefix = false;
9797

98-
if (name[0] == '+' || name[0] == '-') {
98+
if (name.size() > 1 && (name[0] == '+' || name[0] == '-')) {
9999
valid_prefix = name[1] == '[';
100100
if (name[0] == '+')
101101
m_type = eTypeClassMethod;

0 commit comments

Comments
 (0)