[lldb-dev] Platform code should check for null
Carlo Kok
ck at remobjects.com
Tue Nov 6 05:19:16 PST 2012
Platform*.ResolveExecutable has code like:
error = ModuleList::GetSharedModule (module_spec,
exe_module_sp,
module_search_paths_ptr,
NULL,
NULL);
if (exe_module_sp->GetObjectFile() == NULL)
{
exe_module_sp.reset();
error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain the
architecture %s",
exe_file.GetDirectory().AsCString(""),
exe_file.GetDirectory() ? "/" : "",
exe_file.GetFilename().AsCString(""),
exe_arch.GetArchitectureName());
}
However if for whatever reason the file doesn't load (corrupt, missing,
plugin not compiled in? etc) exe_module_sp is null. IMO that check needs
to check exe_module_sp too.
if (exe_module_sp == NULL || exe_module_sp->GetObjectFile() == NULL)
so it gives a nice error instead of a memory access error.
More information about the lldb-dev
mailing list