forked from OSchip/llvm-project
http://llvm.org/bugs/show_bug.cgi?id=11560 lldb::SBTarget::FindFirstType crashes when passed None
Add null checks to several functions. Plus add test scenario for passing None to SBTarget.FindFirstType(None) and friends. llvm-svn: 146540
This commit is contained in:
parent
798b0c8340
commit
c6770763e6
|
@ -1188,7 +1188,7 @@ SBTarget::FindFunctions (const char *name,
|
|||
{
|
||||
if (!append)
|
||||
sc_list.Clear();
|
||||
if (m_opaque_sp)
|
||||
if (name && m_opaque_sp)
|
||||
{
|
||||
const bool symbols_ok = true;
|
||||
return m_opaque_sp->GetImages().FindFunctions (ConstString(name),
|
||||
|
@ -1203,7 +1203,7 @@ SBTarget::FindFunctions (const char *name,
|
|||
lldb::SBType
|
||||
SBTarget::FindFirstType (const char* type)
|
||||
{
|
||||
if (m_opaque_sp)
|
||||
if (type && m_opaque_sp)
|
||||
{
|
||||
size_t count = m_opaque_sp->GetImages().GetSize();
|
||||
for (size_t idx = 0; idx < count; idx++)
|
||||
|
@ -1223,7 +1223,7 @@ SBTarget::FindTypes (const char* type)
|
|||
|
||||
SBTypeList retval;
|
||||
|
||||
if (m_opaque_sp)
|
||||
if (type && m_opaque_sp)
|
||||
{
|
||||
ModuleList& images = m_opaque_sp->GetImages();
|
||||
ConstString name_const(type);
|
||||
|
@ -1251,7 +1251,7 @@ SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
|
|||
{
|
||||
SBValueList sb_value_list;
|
||||
|
||||
if (m_opaque_sp)
|
||||
if (name && m_opaque_sp)
|
||||
{
|
||||
VariableList variable_list;
|
||||
const bool append = true;
|
||||
|
|
|
@ -506,6 +506,9 @@ Module::FindTypes_Impl (const SymbolContext& sc, const ConstString &name, const
|
|||
static const char*
|
||||
StripTypeName(const char* name_cstr)
|
||||
{
|
||||
// Protect against null c string.
|
||||
if (!name_cstr)
|
||||
return name_cstr;
|
||||
const char* skip_namespace = strstr(name_cstr, "::");
|
||||
const char* template_arg_char = strchr(name_cstr, '<');
|
||||
while (skip_namespace != NULL)
|
||||
|
|
|
@ -24,6 +24,7 @@ def fuzz_obj(obj):
|
|||
obj.FindFunctions("the_func", 0xff, True, contextlist)
|
||||
obj.FindFirstType("dont_care")
|
||||
obj.FindTypes("dont_care")
|
||||
obj.FindFirstType(None)
|
||||
obj.GetSourceManager()
|
||||
obj.FindGlobalVariables("my_global_var", 1)
|
||||
address = obj.ResolveLoadAddress(0xffff)
|
||||
|
|
|
@ -69,6 +69,10 @@ class TypeAndTypeListTestCase(TestBase):
|
|||
self.assertTrue(type)
|
||||
self.DebugSBType(type)
|
||||
|
||||
# Pass an empty string. LLDB should not crash. :-)
|
||||
fuzz_types = target.FindTypes(None)
|
||||
fuzz_type = target.FindFirstType(None)
|
||||
|
||||
# Now use the SBTarget.FindFirstType() API to find 'Task'.
|
||||
task_type = target.FindFirstType('Task')
|
||||
self.assertTrue(task_type)
|
||||
|
|
Loading…
Reference in New Issue