[Lldb-commits] [lldb] r146909 - in /lldb/trunk: source/API/SBCommandInterpreter.cpp test/python_api/interpreter/TestCommandInterpreterAPI.py

Johnny Chen johnny.chen at apple.com
Mon Dec 19 13:16:29 PST 2011


Author: johnny
Date: Mon Dec 19 15:16:29 2011
New Revision: 146909

URL: http://llvm.org/viewvc/llvm-project?rev=146909&view=rev
Log:
Work in progress for:

rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBCommandInterpreter APIs.

Modified:
    lldb/trunk/source/API/SBCommandInterpreter.cpp
    lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py

Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=146909&r1=146908&r2=146909&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandInterpreter.cpp (original)
+++ lldb/trunk/source/API/SBCommandInterpreter.cpp Mon Dec 19 15:16:29 2011
@@ -65,7 +65,7 @@
 bool
 SBCommandInterpreter::CommandExists (const char *cmd)
 {
-    if (m_opaque_ptr)
+    if (cmd && m_opaque_ptr)
         return m_opaque_ptr->CommandExists (cmd);
     return false;
 }
@@ -73,7 +73,7 @@
 bool
 SBCommandInterpreter::AliasExists (const char *cmd)
 {
-    if (m_opaque_ptr)
+    if (cmd && m_opaque_ptr)
         return m_opaque_ptr->AliasExists (cmd);
     return false;
 }
@@ -88,7 +88,7 @@
                      m_opaque_ptr, command_line, result.get(), add_to_history);
 
     result.Clear();
-    if (m_opaque_ptr)
+    if (command_line && m_opaque_ptr)
     {
         TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
         Mutex::Locker api_locker;
@@ -98,7 +98,7 @@
     }
     else
     {
-        result->AppendError ("SBCommandInterpreter is not valid");
+        result->AppendError ("SBCommandInterpreter or the command line is not valid");
         result->SetStatus (eReturnStatusFailed);
     }
 

Modified: lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py?rev=146909&r1=146908&r2=146909&view=diff
==============================================================================
--- lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py (original)
+++ lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py Mon Dec 19 15:16:29 2011
@@ -59,6 +59,12 @@
         ci.HandleCommand("process launch", res)
         self.assertTrue(res.Succeeded())
 
+        # Boundary conditions should not crash lldb!
+        self.assertFalse(ci.CommandExists(None))
+        self.assertFalse(ci.AliasExists(None))
+        ci.HandleCommand(None, res)
+        self.assertFalse(res.Succeeded())
+
         process = ci.GetProcess()
         self.assertTrue(process)
 





More information about the lldb-commits mailing list