From 8bb774fc375e2645c85f91c7dd629740e9f76cce Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 27 Dec 2017 23:49:45 -0500 Subject: [PATCH] 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. --- src/kits/debugger/controllers/TeamDebugger.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kits/debugger/controllers/TeamDebugger.cpp b/src/kits/debugger/controllers/TeamDebugger.cpp index faf3944573..d5b3cda0d7 100644 --- a/src/kits/debugger/controllers/TeamDebugger.cpp +++ b/src/kits/debugger/controllers/TeamDebugger.cpp @@ -1,6 +1,6 @@ /* * 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. */ @@ -1532,7 +1532,7 @@ TeamDebugger::_HandleDebuggerMessage(DebugEvent* event) bool handled = false; ThreadHandler* handler = _GetThreadHandler(event->Thread()); - BReference handlerReference(handler); + BReference handlerReference(handler, true); switch (event->EventType()) { case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: @@ -1976,7 +1976,7 @@ TeamDebugger::_HandleImageDebugInfoChanged(image_id imageID) ObjectDeleter threadDeleter(thread); locker.Lock(); ThreadHandler* handler = _GetThreadHandler(thread->ThreadID()); - BReference handlerReference(handler); + BReference handlerReference(handler, true); if (fTeam->StopOnImageLoad()) { bool stop = true;