From 9a2f11cc1fc9b0157e185b39abbd6a50c4cfc8cd Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 30 Sep 2024 19:35:01 +0200 Subject: [PATCH] cid#1607861 Data race condition Change-Id: Ib58f6613b98b2b778c9894359fe92b6fcf33298d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174293 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/dbaccess/AsynchronousLink.hxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/dbaccess/AsynchronousLink.hxx b/include/dbaccess/AsynchronousLink.hxx index 22c40dc5b714..cd1af635c03a 100644 --- a/include/dbaccess/AsynchronousLink.hxx +++ b/include/dbaccess/AsynchronousLink.hxx @@ -38,7 +38,7 @@ namespace dbaui class OAsynchronousLink final { Link m_aHandler; - std::mutex m_aEventSafety; + mutable std::mutex m_aEventSafety; std::mutex m_aDestructionSafety; ImplSVEvent * m_nEventId; DECL_LINK(OnAsyncCall, void*, void); @@ -50,7 +50,11 @@ namespace dbaui OAsynchronousLink( const Link& _rHandler ); ~OAsynchronousLink(); - bool IsRunning() const { return m_nEventId != nullptr; } + bool IsRunning() const + { + std::unique_lock aEventGuard(m_aEventSafety); + return m_nEventId != nullptr; + } void Call( void* _pArgument = nullptr ); void CancelCall();