Do not leak the delegate, as suggested by Stippi

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30355 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes 2009-04-23 21:01:57 +00:00
parent 2384ec2866
commit 6971db8cca

View File

@ -34,24 +34,34 @@
LocalDeviceImpl*
LocalDeviceImpl::CreateControllerAccessor(BPath* path)
{
HCIDelegate* hd = new (std::nothrow)HCIControllerAccessor(path);
if (hd != NULL)
return new (std::nothrow)LocalDeviceImpl(hd);
else
HCIDelegate* delegate = new(std::nothrow) HCIControllerAccessor(path);
if (delegate == NULL)
return NULL;
LocalDeviceImpl* device = new(std::nothrow) LocalDeviceImpl(delegate);
if (device == NULL) {
delete delegate;
return NULL;
}
return device;
}
LocalDeviceImpl*
LocalDeviceImpl::CreateTransportAccessor(BPath* path)
{
HCIDelegate* hd = new (std::nothrow)HCITransportAccessor(path);
if (hd != NULL)
return new (std::nothrow)LocalDeviceImpl(hd);
else
HCIDelegate* delegate = new(std::nothrow) HCITransportAccessor(path);
if (delegate == NULL)
return NULL;
LocalDeviceImpl* device = new(std::nothrow) LocalDeviceImpl(delegate);
if (device == NULL) {
delete delegate;
return NULL;
}
return device;
}