vcl/osx/salinst.cxx |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 226ec5aebb65f4017c29bc3aaacfaa5782dfbbb7
Author: Michael Stahl <mst...@redhat.com>
Date:   Fri Feb 23 12:44:33 2018 +0100

    vcl: race in OSX SalYieldMutex::doRelease
    
    m_nCount must be accessed with m_aMutex locked.
    
    Change-Id: I7e05cac2b549b975804d6061721c1da4d0b9f64e
    Reviewed-on: https://gerrit.libreoffice.org/50236
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Michael Stahl <mst...@redhat.com>

diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index e008357b3641..891281614cb1 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -330,8 +330,10 @@ sal_uInt32 SalYieldMutex::doRelease( const bool bUnlockAll 
)
     sal_uInt32 nCount;
     {
         std::unique_lock<std::mutex> g(m_runInMainMutex);
+        // read m_nCount before doRelease
+        bool const isReleased(bUnlockAll || m_nCount == 1);
         nCount = comphelper::GenericSolarMutex::doRelease( bUnlockAll );
-        if ( 0 == m_nCount && !pInst->IsMainThread() ) {
+        if (isReleased && !pInst->IsMainThread()) {
             m_wakeUpMain = true;
             m_aInMainCondition.notify_all();
         }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to