Author: sas
Date: Mon Jun  5 12:44:04 2017
New Revision: 304725

URL: http://llvm.org/viewvc/llvm-project?rev=304725&view=rev
Log:
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 <men...@fb.com>

Reviewers: lldb-commits, clayborg

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

Modified:
    lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp

Modified: lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp?rev=304725&r1=304724&r2=304725&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp Mon Jun  5 
12:44:04 2017
@@ -95,7 +95,7 @@ bool ObjCLanguage::MethodName::SetName(l
   // 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;


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to