From 9c41922b33303de6f6b9b562c89bdc84ee81605d Mon Sep 17 00:00:00 2001 From: draekko Date: Tue, 21 Feb 2023 05:11:59 -0500 Subject: [PATCH] add missing checks in motif to prevent leaking image data to text targets --- src/lib/platform/XWindowsClipboard.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp index dd3d99fb..8e81cab3 100644 --- a/src/lib/platform/XWindowsClipboard.cpp +++ b/src/lib/platform/XWindowsClipboard.cpp @@ -838,6 +838,22 @@ XWindowsClipboard::motifFillCache() continue; } + if (actualTarget != target) { + LOG((CLOG_DEBUG1 " target %s not same as actual target %s", + XWindowsUtil::atomToString(m_display, target).c_str(), + XWindowsUtil::atomToString(m_display, actualTarget).c_str())); + m_added[format] = false; + continue; + } + + if (targetData.empty()) { + m_added[format] = false; + LOG((CLOG_DEBUG1 " no targetdata for target %s (actual target %s)", + XWindowsUtil::atomToString(m_display, target).c_str(), + XWindowsUtil::atomToString(m_display, actualTarget).c_str())); + continue; + } + if (!converter->toIClipboard(targetData).empty()) { // add to clipboard and note we've done it m_data[format] = converter->toIClipboard(targetData);