From 543d994967628f580eb34d4d0241846eaef3bd7d Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 16 Feb 2012 12:27:46 +0200 Subject: [PATCH] Fix QWindowsClipboard crash when mimeData is NULL. When setting NULL mimeData in QWindowsClipboard::setMimeData, and the OleSetClipboard call failed, the warning print crashed because it tried to access mimeData. Task-number: QTBUG-24327 Change-Id: I1f56fd28c9191a330e14a93b4b11ac9c89db6985 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsclipboard.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 521ca3d..c1167cc 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -326,13 +326,16 @@ void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) const bool newData = !m_data || m_data->mimeData() != mimeData; if (newData) { releaseIData(); - m_data = new QWindowsOleDataObject(mimeData); + if (mimeData) + m_data = new QWindowsOleDataObject(mimeData); } const HRESULT src = OleSetClipboard(m_data); if (src != S_OK) { + QString mimeDataFormats = mimeData ? + mimeData->formats().join(QStringLiteral(", ")) : QString(QStringLiteral("NULL")); qErrnoWarning("OleSetClipboard: Failed to set mime data (%s) on clipboard: %s", - qPrintable(mimeData->formats().join(QStringLiteral(", "))), + qPrintable(mimeDataFormats), QWindowsContext::comErrorString(src).constData()); releaseIData(); return; -- 2.7.4