File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -810,8 +810,11 @@ bool CGUI_Impl::Event_KeyDown(const CEGUI::EventArgs& Args)
810810 // Open the clipboard
811811 OpenClipboard (NULL );
812812
813- // Get the clipboard's data and put it into a char array
814- const wchar_t * ClipboardBuffer = reinterpret_cast <const wchar_t *>(GetClipboardData (CF_UNICODETEXT));
813+ // Get the clipboard's data and lock it
814+ HANDLE hClipData = GetClipboardData (CF_UNICODETEXT);
815+ const wchar_t * ClipboardBuffer = nullptr ;
816+ if (hClipData)
817+ ClipboardBuffer = static_cast <const wchar_t *>(GlobalLock (hClipData));
815818
816819 // Check to make sure we have valid data.
817820 if (ClipboardBuffer)
@@ -828,6 +831,8 @@ bool CGUI_Impl::Event_KeyDown(const CEGUI::EventArgs& Args)
828831 // Don't paste if we're read only
829832 if (WndEdit->isReadOnly ())
830833 {
834+ if (hClipData)
835+ GlobalUnlock (hClipData);
831836 CloseClipboard ();
832837 return true ;
833838 }
@@ -843,6 +848,8 @@ bool CGUI_Impl::Event_KeyDown(const CEGUI::EventArgs& Args)
843848 // Don't paste if we're read only
844849 if (WndEdit->isReadOnly ())
845850 {
851+ if (hClipData)
852+ GlobalUnlock (hClipData);
846853 CloseClipboard ();
847854 return true ;
848855 }
@@ -947,6 +954,9 @@ bool CGUI_Impl::Event_KeyDown(const CEGUI::EventArgs& Args)
947954 }
948955 }
949956
957+ if (hClipData)
958+ GlobalUnlock (hClipData);
959+
950960 // Close the clipboard
951961 CloseClipboard ();
952962 }
You can’t perform that action at this time.
0 commit comments