vcl/win/dtrans/WinClipboard.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
New commits: commit 3015db08c9a8a1b29af1018044955c905c9015aa Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Nov 3 22:49:28 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Nov 3 20:00:35 2024 +0100 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.kagan...@collabora.com> diff --git a/vcl/win/dtrans/WinClipboard.cxx b/vcl/win/dtrans/WinClipboard.cxx index 5d8c7f29095a..dbaa019f14d8 100644 --- a/vcl/win/dtrans/WinClipboard.cxx +++ b/vcl/win/dtrans/WinClipboard.cxx @@ -173,6 +173,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) @@ -181,7 +184,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()) @@ -285,7 +289,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);