forked from OSchip/llvm-project
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:
parent
f74c2348b7
commit
3f0b90dcd0
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue