[Lldb-commits] [lldb] r269686 - Don't crash when OS plug-in returns None from any of the functions we might call.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon May 16 13:07:38 PDT 2016


Author: gclayton
Date: Mon May 16 15:07:38 2016
New Revision: 269686

URL: http://llvm.org/viewvc/llvm-project?rev=269686&view=rev
Log:
Don't crash when OS plug-in returns None from any of the functions we might call. 

<rdar://problem/24489419>

Modified:
    lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=269686&r1=269685&r2=269686&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Mon May 16 15:07:38 2016
@@ -1551,10 +1551,12 @@ ScriptInterpreterPython::OSPlugin_Regist
         PyErr_Print();
         PyErr_Clear();
     }
-    assert(PythonDictionary::Check(py_return.get()) && "get_register_info returned unknown object type!");
-
-    PythonDictionary result_dict(PyRefType::Borrowed, py_return.get());
-    return result_dict.CreateStructuredDictionary();
+    if (py_return.get())
+    {
+        PythonDictionary result_dict(PyRefType::Borrowed, py_return.get());
+        return result_dict.CreateStructuredDictionary();
+    }
+    return StructuredData::DictionarySP();
 }
 
 StructuredData::ArraySP
@@ -1607,10 +1609,12 @@ ScriptInterpreterPython::OSPlugin_Thread
         PyErr_Clear();
     }
 
-    assert(PythonList::Check(py_return.get()) && "get_thread_info returned unknown object type!");
-
-    PythonList result_list(PyRefType::Borrowed, py_return.get());
-    return result_list.CreateStructuredArray();
+    if (py_return.get())
+    {
+        PythonList result_list(PyRefType::Borrowed, py_return.get());
+        return result_list.CreateStructuredArray();
+    }
+    return StructuredData::ArraySP();
 }
 
 // GetPythonValueFormatString provides a system independent type safe way to
@@ -1688,10 +1692,12 @@ ScriptInterpreterPython::OSPlugin_Regist
         PyErr_Clear();
     }
 
-    assert(PythonBytes::Check(py_return.get()) && "get_register_data returned unknown object type!");
-
-    PythonBytes result(PyRefType::Borrowed, py_return.get());
-    return result.CreateStructuredString();
+    if (py_return.get())
+    {
+        PythonBytes result(PyRefType::Borrowed, py_return.get());
+        return result.CreateStructuredString();
+    }
+    return StructuredData::StringSP();
 }
 
 StructuredData::DictionarySP
@@ -1746,10 +1752,12 @@ ScriptInterpreterPython::OSPlugin_Create
         PyErr_Clear();
     }
 
-    assert(PythonDictionary::Check(py_return.get()) && "create_thread returned unknown object type!");
-
-    PythonDictionary result_dict(PyRefType::Borrowed, py_return.get());
-    return result_dict.CreateStructuredDictionary();
+    if (py_return.get())
+    {
+        PythonDictionary result_dict(PyRefType::Borrowed, py_return.get());
+        return result_dict.CreateStructuredDictionary();
+    }
+    return StructuredData::DictionarySP();
 }
 
 StructuredData::ObjectSP




More information about the lldb-commits mailing list