[Lldb-commits] [lldb] r147178 - /lldb/trunk/source/Expression/IRForTarget.cpp

Sean Callanan scallanan at apple.com
Thu Dec 22 13:24:49 PST 2011


Author: spyffe
Date: Thu Dec 22 15:24:49 2011
New Revision: 147178

URL: http://llvm.org/viewvc/llvm-project?rev=147178&view=rev
Log:
Added checking to prevent a rare crash when getting
the name for an external variable in the IR.

Modified:
    lldb/trunk/source/Expression/IRForTarget.cpp

Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=147178&r1=147177&r2=147178&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Thu Dec 22 15:24:49 2011
@@ -1831,19 +1831,27 @@
          global != end;
          ++global)
     {
+        if (!global)
+        {
+            if (m_error_stream)
+                m_error_stream->Printf("Internal error [IRForTarget]: global variable is NULL");
+            
+            return false;
+        }
+        
+        std::string global_name = (*global).getName().str();
+        
         if (log)
             log->Printf("Examining %s, DeclForGlobalValue returns %p", 
-                        (*global).getName().str().c_str(),
+                        global_name.c_str(),
                         DeclForGlobal(global));
-    
-        std::string global_name = (*global).getName().str();
         
         if (global_name.find("OBJC_IVAR") == 0)
         {
             if (!HandleSymbol(global))
             {
                 if (m_error_stream)
-                    m_error_stream->Printf("Error [IRForTarget]: Couldn't find Objective-C indirect ivar symbol %s\n", (*global).getName().str().c_str());
+                    m_error_stream->Printf("Error [IRForTarget]: Couldn't find Objective-C indirect ivar symbol %s\n", global_name.c_str());
                 
                 return false;
             }
@@ -1863,7 +1871,7 @@
             if (!MaybeHandleVariable (global))
             {
                 if (m_error_stream)
-                    m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite external variable %s\n", (*global).getName().str().c_str());
+                    m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite external variable %s\n", global_name.c_str());
                 
                 return false;
             }





More information about the lldb-commits mailing list