[Lldb-commits] [lldb] r146629 - in /lldb/trunk: source/API/SBValue.cpp test/python_api/sbdata/TestSBData.py

Johnny Chen johnny.chen at apple.com
Wed Dec 14 17:55:36 PST 2011


Author: johnny
Date: Wed Dec 14 19:55:36 2011
New Revision: 146629

URL: http://llvm.org/viewvc/llvm-project?rev=146629&view=rev
Log:
http://llvm.org/bugs/show_bug.cgi?id=11579
lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds

SBValue::CreateValueFromAddress() should check the validity of type and its derived pointer type
before using it.  Add a test case.

Modified:
    lldb/trunk/source/API/SBValue.cpp
    lldb/trunk/test/python_api/sbdata/TestSBData.py

Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=146629&r1=146628&r2=146629&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Wed Dec 14 19:55:36 2011
@@ -404,9 +404,8 @@
 SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType type)
 {
     lldb::SBValue result;
-    if (m_opaque_sp)
+    if (m_opaque_sp && type.IsValid() && type.GetPointerType().IsValid())
     {
-        
         SBType real_type(type.GetPointerType());
         
         lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));

Modified: lldb/trunk/test/python_api/sbdata/TestSBData.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/sbdata/TestSBData.py?rev=146629&r1=146628&r2=146629&view=diff
==============================================================================
--- lldb/trunk/test/python_api/sbdata/TestSBData.py (original)
+++ lldb/trunk/test/python_api/sbdata/TestSBData.py Wed Dec 14 19:55:36 2011
@@ -112,6 +112,11 @@
         foobar_addr = star_foobar.GetLoadAddress()
         foobar_addr += 12
 
+        # http://llvm.org/bugs/show_bug.cgi?id=11579
+        # lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds
+        # This should not crash LLDB.
+        nothing = foobar.CreateValueFromAddress("nothing", foobar_addr, star_foobar.GetType().GetBasicType(lldb.eBasicTypeInvalid))
+
         new_foobar = foobar.CreateValueFromAddress("f00", foobar_addr, star_foobar.GetType())
 
         if self.TraceOn():





More information about the lldb-commits mailing list