include/ucbhelper/propertyvalueset.hxx         |    4 +++-
 svl/source/fsstor/fsstorage.cxx                |   19 +++++++++++++------
 svl/source/fsstor/fsstorage.hxx                |    5 +++++
 ucbhelper/source/provider/propertyvalueset.cxx |   23 +++++++++++------------
 4 files changed, 32 insertions(+), 19 deletions(-)

New commits:
commit e3058135a76a74b04be26e6e037f9a4a0ba723ea
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sun Jul 21 20:35:06 2024 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Jul 24 19:20:18 2024 +0200

    cid#1608362 Double unlock
    
    and
    
    cid#1608276 Double lock
    
    Change-Id: I64529c0b9e9b4df2ee51a024522f82051ccea25d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170824
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 2d4aa7861cf036f503e19a6bac460e26b78aa27a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170867
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/include/ucbhelper/propertyvalueset.hxx 
b/include/ucbhelper/propertyvalueset.hxx
index 6fa9930d39cb..b750662976c2 100644
--- a/include/ucbhelper/propertyvalueset.hxx
+++ b/include/ucbhelper/propertyvalueset.hxx
@@ -68,7 +68,7 @@ class SAL_DLLPUBLIC_RTTI PropertyValueSet final :
 
 private:
     const css::uno::Reference< css::script::XTypeConverter >&
-    getTypeConverter();
+    getTypeConverter(const std::unique_lock<std::mutex>& rGuard);
 
     template <class T, T ucbhelper_impl::PropertyValue::*_member_name_>
     T getValue(PropsSet nTypeName, sal_Int32 columnIndex);
@@ -76,6 +76,8 @@ private:
     template <class T, T ucbhelper_impl::PropertyValue::*_member_name_>
     void appendValue(const OUString& rPropName, PropsSet nTypeName, const T& 
rValue);
 
+    css::uno::Any getObjectImpl(const std::unique_lock<std::mutex>& rGuard, 
sal_Int32 columnIndex);
+
 public:
     UCBHELPER_DLLPUBLIC PropertyValueSet(
             const css::uno::Reference< css::uno::XComponentContext >& 
rxContext );
diff --git a/ucbhelper/source/provider/propertyvalueset.cxx 
b/ucbhelper/source/provider/propertyvalueset.cxx
index b019d3b9c8cd..25e850767922 100644
--- a/ucbhelper/source/provider/propertyvalueset.cxx
+++ b/ucbhelper/source/provider/propertyvalueset.cxx
@@ -176,7 +176,7 @@ T PropertyValueSet::getValue(PropsSet nTypeName, sal_Int32 
columnIndex)
     if ( !(rValue.nPropsSet & PropsSet::Object) )
     {
         /* Value is not (yet) available as Any. Create it. */
-        getObject( columnIndex, Reference< XNameAccess >() );
+        getObjectImpl(aGuard, columnIndex);
     }
 
     if ( rValue.nPropsSet & PropsSet::Object )
@@ -196,7 +196,7 @@ T PropertyValueSet::getValue(PropsSet nTypeName, sal_Int32 
columnIndex)
             {
                 /* Last chance. Try type converter service... */
 
-                Reference< XTypeConverter > xConverter = getTypeConverter();
+                Reference< XTypeConverter > xConverter = 
getTypeConverter(aGuard);
                 if ( xConverter.is() )
                 {
                     try
@@ -337,14 +337,8 @@ PropertyValueSet::getCharacterStream( sal_Int32 
columnIndex )
     return getValue<Reference< XInputStream >, 
&ucbhelper_impl::PropertyValue::xCharacterStream>(PropsSet::CharacterStream, 
columnIndex);
 }
 
-
-// virtual
-Any SAL_CALL PropertyValueSet::getObject(
-                                    sal_Int32 columnIndex,
-                                         const Reference< XNameAccess >& )
+Any PropertyValueSet::getObjectImpl(const std::unique_lock<std::mutex>& 
/*rGuard*/, sal_Int32 columnIndex)
 {
-    std::unique_lock aGuard( m_aMutex );
-
     Any aValue;
 
     m_bWasNull = true;
@@ -466,6 +460,13 @@ Any SAL_CALL PropertyValueSet::getObject(
     return aValue;
 }
 
+// virtual
+Any SAL_CALL PropertyValueSet::getObject(sal_Int32 columnIndex, const 
Reference<XNameAccess>&)
+{
+    std::unique_lock aGuard( m_aMutex );
+
+    return getObjectImpl(aGuard, columnIndex);
+}
 
 // virtual
 Reference< XRef > SAL_CALL PropertyValueSet::getRef( sal_Int32 columnIndex )
@@ -519,10 +520,8 @@ sal_Int32 SAL_CALL PropertyValueSet::findColumn( const 
OUString& columnName )
 // Non-interface methods.
 
 
-const Reference< XTypeConverter >& PropertyValueSet::getTypeConverter()
+const Reference< XTypeConverter >& PropertyValueSet::getTypeConverter(const 
std::unique_lock<std::mutex>& /*rGuard*/)
 {
-    std::unique_lock aGuard( m_aMutex );
-
     if ( !m_bTriedToGetTypeConverter && !m_xTypeConverter.is() )
     {
         m_bTriedToGetTypeConverter = true;
commit abb362c3c18021da87789fcea23ed1dcb95a14af
Author:     Caolán McNamara <[email protected]>
AuthorDate: Fri Jul 19 09:52:37 2024 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Jul 24 19:20:05 2024 +0200

    cid#1608321 Double lock
    
    Change-Id: I831db1632e2a8fab9194ffb54df61f55e6304864
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170748
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit ca84e561a0d0bce89258671ab32bcf5fb5a4ca29)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170729
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index 95f498b71ce2..a3be4b3f3e80 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -648,12 +648,11 @@ void SAL_CALL FSStorage::renameElement( const OUString& 
aElementName, const OUSt
     }
 }
 
-void SAL_CALL FSStorage::copyElementTo( const OUString& aElementName,
-                                        const uno::Reference< embed::XStorage 
>& xDest,
-                                        const OUString& aNewName )
+void FSStorage::copyElementToImpl(std::unique_lock<std::mutex>& /*rGuard*/,
+                                  std::u16string_view aElementName,
+                                  const uno::Reference< embed::XStorage >& 
xDest,
+                                  const OUString& aNewName )
 {
-    std::unique_lock aGuard( m_aMutex );
-
     if ( !xDest.is() )
         throw uno::RuntimeException();
 
@@ -719,12 +718,20 @@ void SAL_CALL FSStorage::copyElementTo( const OUString& 
aElementName,
     }
 }
 
+void SAL_CALL FSStorage::copyElementTo( const OUString& aElementName,
+                                        const uno::Reference< embed::XStorage 
>& xDest,
+                                        const OUString& aNewName )
+{
+    std::unique_lock aGuard( m_aMutex );
+    copyElementToImpl(aGuard, aElementName, xDest, aNewName);
+}
+
 void SAL_CALL FSStorage::moveElementTo( const OUString& aElementName,
                                         const uno::Reference< embed::XStorage 
>& xDest,
                                         const OUString& aNewName )
 {
     std::unique_lock aGuard( m_aMutex );
-    copyElementTo( aElementName, xDest, aNewName );
+    copyElementToImpl(aGuard, aElementName, xDest, aNewName);
 
     INetURLObject aOwnURL( m_aURL );
     aOwnURL.Append( aElementName );
diff --git a/svl/source/fsstor/fsstorage.hxx b/svl/source/fsstor/fsstorage.hxx
index 6b02a9a61b83..8b86ed9b1458 100644
--- a/svl/source/fsstor/fsstorage.hxx
+++ b/svl/source/fsstor/fsstorage.hxx
@@ -179,6 +179,11 @@ private:
     css::uno::Reference< css::io::XStream > openStreamElementImpl(
             std::unique_lock<std::mutex>& rGuard,
             std::u16string_view aStreamName, sal_Int32 nOpenMode );
+    void copyElementToImpl(std::unique_lock<std::mutex>& rGuard,
+            std::u16string_view ElementName,
+            const css::uno::Reference< css::embed::XStorage >& xDest,
+            const OUString& rNewName);
+
     void disposeImpl(std::unique_lock<std::mutex>& rGuard);
 };
 

Reply via email to