Remove additional current process tracking in backtrace_all as it can

refer to freed memory.
This commit is contained in:
Robert Shearman 2005-07-14 10:14:44 +00:00 committed by Alexandre Julliard
parent 04a8cff140
commit 0c9195c650
1 changed files with 3 additions and 8 deletions

View File

@ -209,17 +209,13 @@ static void backtrace_all(void)
entry.dwSize = sizeof(entry); entry.dwSize = sizeof(entry);
if (Thread32First(snapshot, &entry)) if (Thread32First(snapshot, &entry))
{ {
struct dbg_process* cp = dbg_curr_process;
DWORD cpid = dbg_curr_pid;
do do
{ {
if (entry.th32OwnerProcessID == GetCurrentProcessId()) continue; if (entry.th32OwnerProcessID == GetCurrentProcessId()) continue;
if (dbg_curr_process && dbg_curr_pid != cpid) if (dbg_curr_process && dbg_curr_pid != entry.th32OwnerProcessID)
dbg_detach_debuggee(); dbg_detach_debuggee();
if (entry.th32OwnerProcessID == cpid) if (entry.th32OwnerProcessID != dbg_curr_pid)
dbg_curr_process = cp;
else if (entry.th32OwnerProcessID != dbg_curr_pid)
{ {
if (!dbg_attach_debuggee(entry.th32OwnerProcessID, FALSE, TRUE)) if (!dbg_attach_debuggee(entry.th32OwnerProcessID, FALSE, TRUE))
{ {
@ -236,9 +232,8 @@ static void backtrace_all(void)
} }
while (Thread32Next(snapshot, &entry)); while (Thread32Next(snapshot, &entry));
if (dbg_curr_process && dbg_curr_pid != cpid) if (dbg_curr_process)
dbg_detach_debuggee(); dbg_detach_debuggee();
dbg_curr_process = cp; dbg_curr_pid = cpid;
} }
CloseHandle(snapshot); CloseHandle(snapshot);
} }