HaikuDepot: Fix leak of ProcessCoordinators.

This function is supposed to take ownership of the coordinator item,
but it didn't do that in all cases. Use a BReference(..., true)
to do that.
This commit is contained in:
Augustin Cavalier
2022-04-26 17:50:53 -04:00
parent a173592b40
commit 7d7de13527
+3 -4
View File
@@ -1419,12 +1419,12 @@ MainWindow::_HandleUserUsageConditionsNotLatest(
void
MainWindow::_AddProcessCoordinator(ProcessCoordinator* item)
{
BReference<ProcessCoordinator> itemRef(item, true);
AutoLocker<BLocker> lock(&fCoordinatorLock);
if (fShouldCloseWhenNoProcessesToCoordinate) {
HDINFO("system shutting down --> new process coordinator [%s] rejected",
item->Name().String());
delete item;
return;
}
@@ -1435,10 +1435,9 @@ MainWindow::_AddProcessCoordinator(ProcessCoordinator* item)
debugger("unable to acquire the process coordinator sem");
HDINFO("adding and starting a process coordinator [%s]",
item->Name().String());
fCoordinator = BReference<ProcessCoordinator>(item);
fCoordinator = itemRef;
fCoordinator->Start();
}
else {
} else {
HDINFO("adding process coordinator [%s] to the queue",
item->Name().String());
fCoordinatorQueue.push(item);