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.

llvm-svn: 146629
This commit is contained in:
Johnny Chen
2011-12-15 01:55:36 +00:00
parent 30373150a1
commit 95873a68f4
2 changed files with 6 additions and 2 deletions

View File

@@ -404,9 +404,8 @@ lldb::SBValue
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)));

View File

@@ -112,6 +112,11 @@ class SBDataAPICase(TestBase):
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():