rdar://problem/10216227

LLDB (python bindings) Crashing in lldb::SBDebugger::DeleteTarget(lldb::SBTarget&)

Need to check the validity of (SBTarget&)target passed to SBDebugger::DeleteTarget()
before calling target->Destroy().

llvm-svn: 147213
This commit is contained in:
Johnny Chen 2011-12-23 00:53:45 +00:00
parent f74c2348b7
commit 3f0b90dcd0
2 changed files with 9 additions and 1 deletions

View File

@ -616,7 +616,7 @@ bool
SBDebugger::DeleteTarget (lldb::SBTarget &target)
{
bool result = false;
if (m_opaque_sp)
if (m_opaque_sp && target.IsValid())
{
// No need to lock, the target list is thread safe
result = m_opaque_sp->GetTargetList().DeleteTarget (target.m_opaque_sp);

View File

@ -28,3 +28,11 @@ class DebuggerAPITestCase(TestBase):
self.dbg.SetPrompt(None)
self.dbg.SetCurrentPlatform(None)
self.dbg.SetCurrentPlatformSDKRoot(None)
@python_api_test
def test_debugger_delete_invalid_target(self):
"""SBDebugger.DeleteTarget() should not crash LLDB given and invalid target."""
target = lldb.SBTarget()
self.assertFalse(target.IsValid())
self.dbg.DeleteTarget(target)