From c6b638267ab97642b2426ddbf2b11f1b73666d5c Mon Sep 17 00:00:00 2001 From: Jan Blackquill Date: Sun, 14 Feb 2021 16:47:49 -0500 Subject: [PATCH] Fix crash on pasting too soon after copying from XWayland There seems to be an interval between when you copy something from a Wayland client and when you attempt to paste it into an X client where m_chunks.first().first is empty, and trying to access its .data() will cause an assertion. While we can't really gracefully handle this situation, we can at least terminate the function early and turn the paste operation into a noop instead of a crash. --- src/xwl/transfer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/xwl/transfer.cpp b/src/xwl/transfer.cpp index f557c0df8c..6ba4c7b234 100644 --- a/src/xwl/transfer.cpp +++ b/src/xwl/transfer.cpp @@ -111,6 +111,7 @@ void TransferWltoX::startTransferFromSource() int TransferWltoX::flushSourceData() { + Q_ASSERT(!m_chunks.isEmpty()); xcb_connection_t *xcbConn = kwinApp()->x11Connection(); xcb_change_property(xcbConn, @@ -258,7 +259,7 @@ void TransferWltoX::handlePropertyDelete() xcb_flush(xcbConn); m_flushPropertyOnDelete = false; endTransfer(); - } else { + } else if (!m_chunks.isEmpty()) { flushSourceData(); } }