diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-11-03 22:49:28 +0500 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2024-11-06 21:02:03 +0100 |
commit | 637583b9f94fe6f7005bda7f3a8c489bec7b3a61 (patch) | |
tree | 47085820e11e6fb4da9ffed98aa9dcfe6435a967 | |
parent | 27f6dd7f3b39f0af513e6034b441918cc6f5afc7 (diff) |
Related: tdf#163730 Avoid potential deadlock
Similar to commit 43e5118496ae0c9b8f81a54574874eda7d439dbb (Related:
tdf#163730 Avoid deadlock, 2024-11-03). I haven't seen this scenario
myself, but seems likely to be possible.
Change-Id: Ie6bb69e7ebe12a69e4dabee9103de32611235807
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175971
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 3015db08c9a8a1b29af1018044955c905c9015aa)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175920
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | vcl/win/dtrans/WinClipboard.cxx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/vcl/win/dtrans/WinClipboard.cxx b/vcl/win/dtrans/WinClipboard.cxx index 5760155beaa1..3603cf55f5d9 100644 --- a/vcl/win/dtrans/WinClipboard.cxx +++ b/vcl/win/dtrans/WinClipboard.cxx @@ -172,6 +172,9 @@ void SAL_CALL CWinClipboard::setContents( const uno::Reference<datatransfer::XTransferable>& xTransferable, const uno::Reference<datatransfer::clipboard::XClipboardOwner>& xClipboardOwner) { + // The object must be destroyed only outside of the mutex lock, because it may call + // CWinClipboard::onReleaseDataObject in another thread of this process synchronously + css::uno::Reference<css::datatransfer::XTransferable> prev_foreignContent; std::unique_lock aGuard(m_aMutex); if (m_bDisposed) @@ -180,7 +183,8 @@ void SAL_CALL CWinClipboard::setContents( IDataObjectPtr pIDataObj; - m_foreignContent.clear(); + prev_foreignContent = std::move(m_foreignContent); // clear m_foreignContent + assert(!m_foreignContent.is()); m_pCurrentOwnClipContent = nullptr; if (xTransferable.is()) @@ -284,7 +288,7 @@ void SAL_CALL CWinClipboard::removeClipboardListener( void CWinClipboard::handleClipboardContentChanged() { // The object must be destroyed only outside of the mutex lock, because it may call - // CWinClipboard::onReleaseDataObject in another thread of this process + // CWinClipboard::onReleaseDataObject in another thread of this process synchronously css::uno::Reference<css::datatransfer::XTransferable> old_foreignContent; { std::unique_lock aGuard(m_aMutex); |