fdo#66324 fix locking in webdav_ucp::Content::getResourceType()
Crash in there while accessing an evidently deleted DAVResourceAccess
instance with about 4 other threads also in various webdav_ucp::Content
methods.
The problem is apparently that the "outer" getResourceType() passes the
m_xResAccess to the "inner" getResourceType(), which accesses it
without locking the mutex, while another thread resets m_xResAccess
and thereby deletes the current instance.
(regression from 0c3500115c4fd86284a027fc32be704afcf77061)
Change-Id: I1c67021c536e303d766c7ff93fb71e40f991f3af
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index 4ad76c4..49e8655 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -3164,7 +3164,19 @@ Content::ResourceType Content::getResourceType(
const uno::Reference< ucb::XCommandEnvironment >& xEnv )
throw ( uno::Exception )
{
return getResourceType( xEnv, m_xResAccess );
SAL_WNODEPRECATED_DECLARATIONS_PUSH
std::auto_ptr< DAVResourceAccess > xResAccess;
SAL_WNODEPRECATED_DECLARATIONS_POP
{
osl::MutexGuard aGuard( m_aMutex );
xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) );
}
Content::ResourceType const ret = getResourceType( xEnv, xResAccess );
{
osl::Guard< osl::Mutex > aGuard( m_aMutex );
m_xResAccess.reset( new DAVResourceAccess( *xResAccess.get() ) );
}
return ret;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */