sd/source/console/PresenterTimer.cxx |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 6fd05636e2b14806355c2a612de5755f1f6b801d
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Nov 29 21:45:48 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sat Nov 30 21:12:16 2024 +0100

    cid#1557258 Data race condition
    
    Change-Id: Iaf4fdba3696669763511aa476e53a0fea36a05c0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177589
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sd/source/console/PresenterTimer.cxx 
b/sd/source/console/PresenterTimer.cxx
index cffb2dc738fc..d48c0d608bb3 100644
--- a/sd/source/console/PresenterTimer.cxx
+++ b/sd/source/console/PresenterTimer.cxx
@@ -260,12 +260,15 @@ void TimerScheduler::CancelTask (const sal_Int32 nTaskId)
 
 void TimerScheduler::NotifyTermination()
 {
-    std::shared_ptr<TimerScheduler> const 
pInstance(TimerScheduler::mpInstance);
-    if (!pInstance)
+    std::shared_ptr<TimerScheduler> pInstance;
     {
-        return;
+        std::scoped_lock aGuard (maInstanceMutex);
+        pInstance = TimerScheduler::mpInstance;
     }
 
+    if (!pInstance)
+        return;
+
     {
         std::scoped_lock aGuard(pInstance->maTaskContainerMutex);
         pInstance->maScheduledTasks.clear();
@@ -274,9 +277,7 @@ void TimerScheduler::NotifyTermination()
     {
         std::scoped_lock aGuard(pInstance->maCurrentTaskMutex);
         if (pInstance->mpCurrentTask)
-        {
             pInstance->mpCurrentTask->mbIsCanceled = true;
-        }
     }
 
     pInstance->m_Shutdown.set();

Reply via email to