While looking at the code, I found two memory leaks:
* UpdateUserListener() did not delete the copiedListener in case adding the monitor listener failed. * RemoveListener() did never delete UserNodeListeners, IOW user node monitors were never freed! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28787 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8aafdd05fc
commit
c0c4841c24
@ -268,6 +268,12 @@ NodeMonitorService::_RemoveListener(monitor_listener *listener)
|
||||
monitor->listeners.Remove(listener);
|
||||
list_remove_link(listener);
|
||||
|
||||
if (dynamic_cast<UserNodeListener*>(listener->listener) != NULL) {
|
||||
// This is a listener we copied ourselves in UpdateUserListener(),
|
||||
// so we have to delete it here.
|
||||
delete listener->listener;
|
||||
}
|
||||
|
||||
delete listener;
|
||||
|
||||
if (monitor->listeners.IsEmpty())
|
||||
@ -907,7 +913,12 @@ NodeMonitorService::UpdateUserListener(io_context *context, dev_t device,
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
return _AddMonitorListener(context, monitor, flags, *copiedListener);
|
||||
status_t status = _AddMonitorListener(context, monitor, flags,
|
||||
*copiedListener);
|
||||
if (status != B_OK)
|
||||
delete copiedListener;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user