Work in progress for:

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

Add a NULL check for SBValue.CreateValueFromExpression().

llvm-svn: 146954
This commit is contained in:
Johnny Chen 2011-12-20 01:52:44 +00:00
parent 0ffc31c55b
commit 50660440a1
2 changed files with 9 additions and 2 deletions

View File

@ -392,8 +392,11 @@ SBValue::CreateValueFromExpression (const char *name, const char* expression)
true, // keep in memory
eNoDynamicValues,
result_valobj_sp);
result_valobj_sp->SetName(ConstString(name));
result = SBValue(result_valobj_sp);
if (result_valobj_sp)
{
result_valobj_sp->SetName(ConstString(name));
result = SBValue(result_valobj_sp);
}
}
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)

View File

@ -130,6 +130,10 @@ class ChangeValueAPITestCase(TestBase):
self.assertTrue (error.Success(), "Got a changed value for sp")
self.assertTrue (actual_value == 1, "Got the right changed value for sp.")
# Boundary condition test the SBValue.CreateValueFromExpression() API.
# LLDB should not crash!
nosuchval = mine_value.CreateValueFromExpression(None, None)
process.Continue()
self.assertTrue(process.GetState() == lldb.eStateStopped)