[Lldb-commits] [lldb] r146911 - in /lldb/trunk: source/Interpreter/CommandReturnObject.cpp test/python_api/interpreter/TestCommandInterpreterAPI.py

Johnny Chen johnny.chen at apple.com
Mon Dec 19 13:36:24 PST 2011


Author: johnny
Date: Mon Dec 19 15:36:23 2011
New Revision: 146911

URL: http://llvm.org/viewvc/llvm-project?rev=146911&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 SBCommandReturnObject.AppendMessage().

Modified:
    lldb/trunk/source/Interpreter/CommandReturnObject.cpp
    lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py

Modified: lldb/trunk/source/Interpreter/CommandReturnObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandReturnObject.cpp?rev=146911&r1=146910&r2=146911&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandReturnObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandReturnObject.cpp Mon Dec 19 15:36:23 2011
@@ -57,6 +57,8 @@
 void
 CommandReturnObject::AppendErrorWithFormat (const char *format, ...)
 {
+    if (!format)
+        return;
     va_list args;
     va_start (args, format);
     StreamString sstrm;
@@ -76,6 +78,8 @@
 void
 CommandReturnObject::AppendMessageWithFormat (const char *format, ...)
 {
+    if (!format)
+        return;
     va_list args;
     va_start (args, format);
     StreamString sstrm;
@@ -88,6 +92,8 @@
 void
 CommandReturnObject::AppendWarningWithFormat (const char *format, ...)
 {
+    if (!format)
+        return;
     va_list args;
     va_start (args, format);
     StreamString sstrm;
@@ -100,6 +106,8 @@
 void
 CommandReturnObject::AppendMessage (const char *in_string, int len)
 {
+    if (!in_string)
+        return;
     if (len < 0)
         len = ::strlen (in_string);
     GetOutputStream().Printf("%*.*s\n", len, len, in_string);
@@ -108,6 +116,8 @@
 void
 CommandReturnObject::AppendWarning (const char *in_string, int len)
 {
+    if (!in_string)
+        return;
     if (len < 0)
         len = ::strlen (in_string);
     GetErrorStream().Printf("warning: %*.*s\n", len, len, in_string);
@@ -119,6 +129,8 @@
 void
 CommandReturnObject::AppendRawWarning (const char *in_string, int len)
 {
+    if (!in_string)
+        return;
     if (len < 0)
         len = ::strlen (in_string);
     GetErrorStream().Printf("%*.*s", len, len, in_string);
@@ -129,7 +141,6 @@
 {
     if (!in_string)
         return;
-
     if (len < 0)
         len = ::strlen (in_string);
     GetErrorStream().Printf ("error: %*.*s\n", len, len, in_string);
@@ -150,6 +161,8 @@
 void
 CommandReturnObject::AppendRawError (const char *in_string, int len)
 {
+    if (!in_string)
+        return;
     if (len < 0)
         len = ::strlen (in_string);
     GetErrorStream().Printf ("%*.*s", len, len, in_string);

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=146911&r1=146910&r2=146911&view=diff
==============================================================================
--- lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py (original)
+++ lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py Mon Dec 19 15:36:23 2011
@@ -64,6 +64,10 @@
         self.assertFalse(ci.AliasExists(None))
         ci.HandleCommand(None, res)
         self.assertFalse(res.Succeeded())
+        res.AppendMessage("Just appended a message.")
+        res.AppendMessage(None)
+        if self.TraceOn():
+            print res
 
         process = ci.GetProcess()
         self.assertTrue(process)





More information about the lldb-commits mailing list