include/ucbhelper/propertyvalueset.hxx         |    4 +++-
 ucbhelper/source/provider/propertyvalueset.cxx |   23 +++++++++++------------
 2 files changed, 14 insertions(+), 13 deletions(-)

New commits:
commit 2d4aa7861cf036f503e19a6bac460e26b78aa27a
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Jul 21 20:35:06 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Jul 22 09:35:00 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 <caolan.mcnam...@collabora.com>

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;

Reply via email to