cid#1500603 Resource leak

don't mix std::unique_ptr and rtl::Reference

I don't know why mess around with osl_atomic_increment/osl_atomic_decrement,
but at least sync with the pattern in use at
ucb/source/ucp/tdoc/tdoc_storage.cxx StorageElementFactory::createStorage

Change-Id: I25fc57d8e886bab3990a63543212efa67ac9772f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139811
Tested-by: Jenkins
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2022-09-12 16:13:21 +01:00
parent a56e5434a4
commit e30f85f5b4

View File

@@ -44,12 +44,12 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession(
if ( aIt == m_aMap.end() )
{
std::unique_ptr< DAVSession > xElement(
rtl::Reference< CurlSession > xElement(
new CurlSession(rxContext, this, inUri, rFlags, *m_xProxyDecider) );
aIt = m_aMap.emplace( inUri, xElement.get() ).first;
aIt->second->m_aContainerIt = aIt;
xElement.release();
return aIt->second;
}
else if ( osl_atomic_increment( &aIt->second->m_nRefCount ) > 1 )
@@ -63,9 +63,10 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession(
osl_atomic_decrement( &aIt->second->m_nRefCount );
aIt->second->m_aContainerIt = m_aMap.end();
aIt->second = new CurlSession(rxContext, this, inUri, rFlags, *m_xProxyDecider);
rtl::Reference< CurlSession > xNewStorage = new CurlSession(rxContext, this, inUri, rFlags, *m_xProxyDecider);
aIt->second = xNewStorage.get();
aIt->second->m_aContainerIt = aIt;
return aIt->second;
return xNewStorage;
}
}