framework/source/uielement/recentfilesmenucontroller.cxx |   13 ++++++++++---
 sfx2/source/appl/preventduplicateinteraction.cxx         |    1 +
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit f0f47796899666e32bc0763f0846542ed199799f
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon Aug 26 20:18:03 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Aug 26 22:39:57 2024 +0200

    cid#1608206 Double lock
    
    Change-Id: I162e10b672277c77a7e0591b532d9197a79fc6d1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172437
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins

diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx 
b/framework/source/uielement/recentfilesmenucontroller.cxx
index b8bbdd29169e..a7cb312ffa50 100644
--- a/framework/source/uielement/recentfilesmenucontroller.cxx
+++ b/framework/source/uielement/recentfilesmenucontroller.cxx
@@ -99,6 +99,7 @@ private:
     virtual void impl_setPopupMenu() override;
     void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & 
rPopupMenu );
     void executeEntry( sal_Int32 nIndex );
+    void executeEntryImpl(std::unique_lock<std::mutex>& rGuard, sal_Int32 
nIndex);
 
     std::vector<std::pair<OUString, bool>>   m_aRecentFilesItems;
     bool                      m_bDisabled : 1;
@@ -330,7 +331,7 @@ void RecentFilesMenuController::fillPopupMenu( Reference< 
css::awt::XPopupMenu >
     }
 }
 
-void RecentFilesMenuController::executeEntry( sal_Int32 nIndex )
+void RecentFilesMenuController::executeEntryImpl(std::unique_lock<std::mutex>& 
rGuard, sal_Int32 nIndex)
 {
     if (( nIndex < 0 ) ||
         ( nIndex >= sal::static_int_cast<sal_Int32>( 
m_aRecentFilesItems.size() )))
@@ -350,7 +351,13 @@ void RecentFilesMenuController::executeEntry( sal_Int32 
nIndex )
         aArgsList.realloc(aArgsList.size()+1);
         aArgsList.getArray()[aArgsList.size()-1] = 
comphelper::makePropertyValue(u"ReadOnly"_ustr, true);
     }
-    dispatchCommand(m_aRecentFilesItems[nIndex].first, aArgsList, 
u"_default"_ustr);
+    dispatchCommandImpl(rGuard, m_aRecentFilesItems[nIndex].first, aArgsList, 
u"_default"_ustr);
+}
+
+void RecentFilesMenuController::executeEntry( sal_Int32 nIndex )
+{
+    std::unique_lock aLock(m_aMutex);
+    executeEntryImpl(aLock, nIndex);
 }
 
 // XEventListener
@@ -477,7 +484,7 @@ void SAL_CALL RecentFilesMenuController::dispatch(
         aEntryArg = aURL.Complete.subView( nEntryPos, nAddArgs-nEntryPos );
 
     sal_Int32 nEntry = o3tl::toInt32(aEntryArg);
-    executeEntry( nEntry );
+    executeEntryImpl(aLock, nEntry);
 }
 
 }
commit e5924bdc228d8ff7ae6e4ff47bf2b79488c6dcfe
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon Aug 26 20:02:22 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Aug 26 22:39:47 2024 +0200

    cid#1607801 Data race condition
    
    Change-Id: I8825eb9cd1a8a3b26f66fd345f7a7f9b827cd50c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172436
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sfx2/source/appl/preventduplicateinteraction.cxx 
b/sfx2/source/appl/preventduplicateinteraction.cxx
index 694591225ee4..3395eea7250a 100644
--- a/sfx2/source/appl/preventduplicateinteraction.cxx
+++ b/sfx2/source/appl/preventduplicateinteraction.cxx
@@ -200,6 +200,7 @@ bool PreventDuplicateInteraction::getInteractionInfo(const 
css::uno::Type&
 
 void SAL_CALL PreventDuplicateInteraction::initialize(const 
css::uno::Sequence<css::uno::Any>& rArguments)
 {
+    std::unique_lock aLock(m_aLock);
     // If we're re-initialized to set a specific new window as a parent then 
drop our temporary
     // dialog parent
     css::uno::Reference<css::lang::XInitialization> xHandler(m_xHandler, 
css::uno::UNO_QUERY);

Reply via email to