From 91e41296152e7a54dedaba57531cf509311dfc43 Mon Sep 17 00:00:00 2001 From: Muhammad Rifqi Priyo Susanto Date: Fri, 5 Jan 2024 03:24:50 +0700 Subject: [PATCH] Windows: Return early if the clipboard data is not Unicode text --- source/Irrlicht/COSOperator.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/Irrlicht/COSOperator.cpp b/source/Irrlicht/COSOperator.cpp index d2b3b8d..778872a 100644 --- a/source/Irrlicht/COSOperator.cpp +++ b/source/Irrlicht/COSOperator.cpp @@ -159,10 +159,11 @@ const c8* COSOperator::getTextFromClipboard() const if (!OpenClipboard(NULL)) return 0; - wchar_t * buffer = 0; - HANDLE hData = GetClipboardData( CF_UNICODETEXT ); - buffer = (wchar_t*) GlobalLock( hData ); + if (hData == NULL) // Probably not in Unicode text format + return 0; + + wchar_t * buffer = (wchar_t*) GlobalLock( hData ); core::wStringToUTF8(ClipboardBuf, buffer);