<rdar://10949461>
Only set the ProcessSP when the attach is successful.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151741 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 7dbcf95..58a6814 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -812,8 +812,6 @@
if (process_sp)
{
- sb_process.SetSP (process_sp);
-
ProcessAttachInfo &attach_info = sb_attach_info.ref();
lldb::pid_t attach_pid = attach_info.GetProcessID();
if (attach_pid != LLDB_INVALID_PROCESS_ID)
@@ -825,11 +823,15 @@
attach_info.SetUserID(instance_info.GetEffectiveUserID());
}
}
- error.SetError (process_sp->Attach (attach_info));
- // If we are doing synchronous mode, then wait for the
- // process to stop!
- if (target_sp->GetDebugger().GetAsyncExecution () == false)
- process_sp->WaitForProcessToStop (NULL);
+ error.SetError (process_sp->Attach (attach_info));
+ if (error.Success())
+ {
+ sb_process.SetSP (process_sp);
+ // If we are doing synchronous mode, then wait for the
+ // process to stop!
+ if (target_sp->GetDebugger().GetAsyncExecution () == false)
+ process_sp->WaitForProcessToStop (NULL);
+ }
}
else
{