summaryrefslogtreecommitdiff
path: root/ucb/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-09-12 16:13:21 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-09-14 09:52:43 +0200
commite30f85f5b4de09a2e9fbe7f4c4af5ca7364e96ae (patch)
treedcbb239ab74da5fffb6dfae0e54c3323ff2e0753 /ucb/source
parenta56e5434a4ed453b55b8f060ed18404d77a9fb10 (diff)
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>
Diffstat (limited to 'ucb/source')
-rw-r--r--ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx b/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
index f2379d2cc33c..910e7f04b959 100644
--- a/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVSessionFactory.cxx
@@ -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;
}
}