[Lldb-commits] [lldb] r308896 - Don't crash when hostname is empty. StringRef will assert and kill your program.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 24 09:47:04 PDT 2017


Author: gclayton
Date: Mon Jul 24 09:47:04 2017
New Revision: 308896

URL: http://llvm.org/viewvc/llvm-project?rev=308896&view=rev
Log:
Don't crash when hostname is empty. StringRef will assert and kill your program.


Modified:
    lldb/trunk/source/Utility/UriParser.cpp

Modified: lldb/trunk/source/Utility/UriParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/UriParser.cpp?rev=308896&r1=308895&r2=308896&view=diff
==============================================================================
--- lldb/trunk/source/Utility/UriParser.cpp (original)
+++ lldb/trunk/source/Utility/UriParser.cpp Mon Jul 24 09:47:04 2017
@@ -43,7 +43,7 @@ bool UriParser::Parse(llvm::StringRef ur
       ((path_pos != std::string::npos) ? path_pos : uri.size()) - host_pos);
 
   // Extract hostname
-  if (host_port[0] == '[') {
+  if (!host_port.empty() && host_port[0] == '[') {
     // hostname is enclosed with square brackets.
     pos = host_port.find(']');
     if (pos == std::string::npos)




More information about the lldb-commits mailing list