Debugger: Fix a memory leak.

TeamDebugger:
- In several cases, BReferences on thread handlers after a call to
  _GetThreadHandler() weren't correctly initialized to account for
  that function implicitly acquiring a reference on our behalf, leading
  to the reference count to spiral out of control, and consequently the
  handler would never be freed. Found while attempting to address
  #13800, likely more to come.
This commit is contained in:
Rene Gollent 2017-12-27 23:49:45 -05:00
parent 16b34a8fc7
commit 8bb774fc37

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2010-2016, Rene Gollent, rene@gollent.com. * Copyright 2010-2017, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@ -1532,7 +1532,7 @@ TeamDebugger::_HandleDebuggerMessage(DebugEvent* event)
bool handled = false; bool handled = false;
ThreadHandler* handler = _GetThreadHandler(event->Thread()); ThreadHandler* handler = _GetThreadHandler(event->Thread());
BReference<ThreadHandler> handlerReference(handler); BReference<ThreadHandler> handlerReference(handler, true);
switch (event->EventType()) { switch (event->EventType()) {
case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED:
@ -1976,7 +1976,7 @@ TeamDebugger::_HandleImageDebugInfoChanged(image_id imageID)
ObjectDeleter<ImageInfoPendingThread> threadDeleter(thread); ObjectDeleter<ImageInfoPendingThread> threadDeleter(thread);
locker.Lock(); locker.Lock();
ThreadHandler* handler = _GetThreadHandler(thread->ThreadID()); ThreadHandler* handler = _GetThreadHandler(thread->ThreadID());
BReference<ThreadHandler> handlerReference(handler); BReference<ThreadHandler> handlerReference(handler, true);
if (fTeam->StopOnImageLoad()) { if (fTeam->StopOnImageLoad()) {
bool stop = true; bool stop = true;